{"id":22486845,"url":"https://github.com/restberry/restberry","last_synced_at":"2025-12-18T07:02:19.251Z","repository":{"id":13428952,"uuid":"16117738","full_name":"restberry/restberry","owner":"restberry","description":"Framework for setting up RESTful JSON APIs with NodeJS.","archived":false,"fork":false,"pushed_at":"2016-11-09T12:26:41.000Z","size":285,"stargazers_count":117,"open_issues_count":2,"forks_count":10,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-09-20T10:53:59.713Z","etag":null,"topics":["javascript","nodejs","npm","restberry"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/restberry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-21T20:20:12.000Z","updated_at":"2024-11-30T05:39:12.000Z","dependencies_parsed_at":"2022-09-26T17:50:39.348Z","dependency_job_id":null,"html_url":"https://github.com/restberry/restberry","commit_stats":null,"previous_names":["materik/restberry"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/restberry/restberry","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restberry%2Frestberry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restberry%2Frestberry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restberry%2Frestberry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restberry%2Frestberry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/restberry","download_url":"https://codeload.github.com/restberry/restberry/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/restberry%2Frestberry/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27792994,"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","status":"online","status_checked_at":"2025-12-18T02:00:09.725Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["javascript","nodejs","npm","restberry"],"created_at":"2024-12-06T17:15:28.181Z","updated_at":"2025-12-18T07:02:19.213Z","avatar_url":"https://github.com/restberry.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![](logo.png)](http://restberry.com)\n\n[![](https://img.shields.io/badge/contact-@thematerik-blue.svg?style=flat-square)](http://twitter.com/thematerik)\n[![](https://img.shields.io/npm/v/restberry.svg?style=flat-square)](https://www.npmjs.com/package/restberry)\n[![](https://img.shields.io/npm/dm/restberry.svg?style=flat-square)](https://www.npmjs.com/package/restberry)\n[![](https://img.shields.io/travis/materik/restberry.svg?style=flat-square)](https://travis-ci.org/materik/restberry)\n\n\u003e Restberry works with both Express and Restify!\n\nFramework for setting up RESTful JSON APIs with NodeJS. Define your models and setup CRUD API\ncalls without needing to write any code (see [Usage](#usage)). All API calls will handle\nand identify issues and throw necessary HTTP responses and easy to debug error\nresponses. Restberry also handles authentication and permission checks and\nthrows appropriate errors.\n\n## Install\n\n```bash\nnpm install restberry\n```\n\n## Example\n\nSee [``example``](/example) for a detailed documentation of how you setup a Restberry app.\n\n## Usage\n\n```javascript\nvar restberry = require('restberry');\n\nrestberry\n    .config({\n        apiPath: '/api/v1',\n        port: 5000,\n    })\n    .listen();\n\nrestberry.model('Foo')\n    .schema({\n        name: {type: String},\n    })\n    .routes\n        .addCreateRoute()\n        .addReadManyRoute();\n\nrestberry.model('Bar')\n    .schema({\n        foo: {type: restberry.odm.ObjectId, ref: 'Foo'},\n        name: {type: String},\n    })\n    .routes\n        .addCRUDRoutes({\n            parentModel: 'Foo',\n        });\n```\n\n**NOTE:** By default, Restberry integrates with ExpressJS and Mongoose but it\ncan be hooked up with other packages. See more usages in the tests and dependent\npackages like:\n- [`restberry-express`](https://github.com/materik/restberry-express)\n- [`restberry-mongoose`](https://github.com/materik/restberry-mongoose)\n- [`restberry-restify`](https://github.com/materik/restberry-restify)\n\n## Response examples\n\nAll these responses below are automatically handled without needing to write any\nadditional code.\n\n* **200** OK\n```bash\n2014-05-11T11:55:53.916Z|172.16.122.129|GET|/api/v1/foos/536f6549e88ad2b5a71ffdc6|\u003c{}\u003e\n2014-05-11T11:55:53.920Z|172.16.122.129|200|\u003c{\n  \"foo\": {\n    \"href\": \"/api/v1/foos/536f6549e88ad2b5a71ffdc7\",\n    \"id\": \"536f6549e88ad2b5a71ffdc7\",\n    \"name\": \"test\"\n  }\n}\u003e\n```\n\n* **201** CREATED\n```bash\n2014-05-11T11:55:54.210Z|172.16.122.129|POST|/api/v1/foos|\u003c{\n  \"name\": \"test\"\n}\u003e\n2014-05-11T11:55:54.210Z|172.16.122.129|201|\u003c{\n  \"foo\": {\n    \"href\": \"/api/v1/foos/536f654ae88ad2b5a71ffdcb\",\n    \"id\": \"536f654ae88ad2b5a71ffdcb\",\n    \"name\": \"test\"\n  }\n}\u003e\n```\n\n* **204** NO CONTENT\n```bash\n2014-05-11T11:55:52.575Z|172.16.122.129|DELETE|/api/v1/foos/536f6548e88ad2b5a71ffdb7|\u003c{}\u003e\n2014-05-11T11:55:52.579Z|172.16.122.129|204|\n```\n\n**NOTE:** See [`restberry-errors`](https://github.com/materik/restberry-errors) for possible error responses.\n\n## Authentication\n\nSee [`restberry-passport`](https://github.com/materik/restberry-passport).\n\n## Routing\n\n```javascript\nrestberry.model('Foo')\n    .routes\n        .addCreateRoute()  // POST /foos\n        .addDeleteRoute()  // DELETE /foos/:id\n        .addPartialUpdateRoute()  // POST /foos/:id\n        .addReadManyRoute()  // GET /foos\n        .addReadRoute()  // GET /foos/:id\n        .addUpdateRoute()  // PUT /foos/:id\n        .addCRUDRoutes()  // All of the above...\n```\n\nHandle action query strings like this:\n\n```javascript\nrestberry.model('Foo')\n    .routes\n        .addPartialUpdateRoutes({\n            actions: {\n                build: function(req, res, next) {\n                    ...\n                },  // POST /foos/:id?action=build\n            },\n        })\n```\n\nAnd Handle parent models like this:\n\n```javascript\nrestberry.model('Foo')\n    .routes\n        .addCreateRoutes({\n            parentModel: restberry.model('Bar'),\n        })  // POST /bars/:id/foos\n```\n\n**NOTE:** this can only be applied to ReadMany and Create.\n\nYou can also create custom routes. The possible configurations you can make are:\n\n```javascript\nrestberry\n    .routes\n        .addCustomRoutes({\n            action: function(req, res, next) {\n                ...\n            },\n            apiPath: '/api/v1',  // overrides the one set on Restberry\n            actions: { },\n            loginRequired: false,  // should authenticate the request\n            method: 'GET',  // choices: DELETE, GET, POST, PUT\n            parentModel: restberry.model('Bar'),\n            path: '/path/to',  // the path of the route, will append apiPath\n            postAction: function(json, req, res, next) {\n                ...\n            },  // will be executed after action\n            preAction: function(req, res, next) {\n                ...\n            },  // will be executed before action\n            verbose: false,  // will print the API call on initiation\n        })\n```\n\n**NOTE:** you can set these properties to all the predefined API definitions,\nyou won't be able to override `action` however.\n\n## Run the tests\n\n```bash\nnpm test\n```\n\n## Further reading\n\nI have written an article series on RESTful JSON API design which this package is base upon, you can find the three parts here: [part 1](http://materik.tumblr.com/post/98324672516/restful-json-api-design-part-1), [part 2](http://materik.tumblr.com/post/99806761591/restful-json-api-design-part-2) and\n[part 3](http://materik.tumblr.com/post/101938795476/restful-json-api-design-part-3).\n\n## Contact\n\nI'm really interested to here what you guys think of Restberry, especially if\nyou have any suggestions to improve the package. Please contact me at\nthematerik@gmail.com.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frestberry%2Frestberry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frestberry%2Frestberry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frestberry%2Frestberry/lists"}