{"id":21002515,"url":"https://github.com/pimatic/decl-api","last_synced_at":"2026-04-22T12:35:13.637Z","repository":{"id":17520014,"uuid":"20308007","full_name":"pimatic/decl-api","owner":"pimatic","description":"Declarative definition for REST and real-time APIs","archived":false,"fork":false,"pushed_at":"2019-03-24T17:32:58.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-20T09:19:27.749Z","etag":null,"topics":["api","rest"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pimatic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-29T20:49:10.000Z","updated_at":"2019-03-24T17:32:59.000Z","dependencies_parsed_at":"2022-09-24T16:50:40.757Z","dependency_job_id":null,"html_url":"https://github.com/pimatic/decl-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pimatic%2Fdecl-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pimatic%2Fdecl-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pimatic%2Fdecl-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pimatic%2Fdecl-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pimatic","download_url":"https://codeload.github.com/pimatic/decl-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243419074,"owners_count":20287805,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","rest"],"created_at":"2024-11-19T08:18:58.910Z","updated_at":"2025-12-28T12:26:32.658Z","avatar_url":"https://github.com/pimatic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"decl-api\n========\n\nDeclarative API definition for REST and real time APIs. \n\n## API-Definition\n\nAn API is defined by a JSON object:\n\n```coffee\ndeclapi = require('../index.js')\nt = declapi.types\n\napi = {}\napi.todo = {\n  actions:\n    listTasks:\n      rest:\n        type: \"GET\"\n        url: \"/api/tasks\"\n      description: \"Lists all tasks\"\n      params: {}\n      result:\n        tasks:\n          type: t.array \n    getTask:\n      description: \"Get a task by id\"\n      rest:\n        type: \"GET\"\n        url: \"/api/tasks/:taskId\"\n      params:\n        taskId:\n          type: t.string\n      result:\n        task:\n          type: t.object\n    addTask:\n      description: \"Adds a task\"\n      rest:\n        type: \"POST\"\n        url: \"/api/tasks\"\n      params:\n        taskId:\n          type: t.string\n        task:\n          type: t.object\n          properties:\n            description:\n              type: t.string\n            done:\n              type: t.boolean\n              optional: yes\n      result:\n        task:\n          type: t.object\n          properties:\n            description:\n              type: t.string\n            done:\n              type: t.boolean\n}\n```\n\n## Implementation\n\nYour Controller must implement the declared functions:\n\n```coffee\nTodoApp = {\n  tasks: []\n  listTasks: -\u003e @tasks\n  getTask: (taskId) -\u003e \n    for t in @tasks\n      if t.id is taskId\n        return task\n    return null\n  addTask: (taskId, task) -\u003e\n    unless task.done then task.done = no\n    task.id = taskId\n    @tasks.push task\n    return task\n}\n```\n\n## Binding\n\n### Express\n    \n```coffee\napp = # Your express app\ndeclapi = env.require 'decl-api'\ntodoApp = new TodoApp()\ndeclapi.createExpressRestApi(app, api.todo, todoApp)\n```\n\n## REST-API\n\n### listTasks\nReturns the task list as JSON object\n\n    GET /api/tasks \n    RESPONSE {success: true, tasks: [...]}\n\n### addTask\nCreates a task with the id: someId and returns it as JSON object\n\n    POST /api/tasks/someId\n    task[description]=\"some description\"\n    task[done]=false\n    RESPONSE\n    {success: true, task: {id: \"someId\", description: \"some description\", done: false}}\n\n### getTask\nReturns the task with id == someId\n\n    GET /api/tasks/someId\n    RESPONSE\n    {success: true, task: {id: \"someId\", description: \"some description\", done: false}}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpimatic%2Fdecl-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpimatic%2Fdecl-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpimatic%2Fdecl-api/lists"}