{"id":19621301,"url":"https://github.com/commenthol/veloze-restbase","last_synced_at":"2026-02-10T20:30:55.134Z","repository":{"id":173150593,"uuid":"628494325","full_name":"commenthol/veloze-restbase","owner":"commenthol","description":"Rest-API to database using JSON-schema","archived":false,"fork":false,"pushed_at":"2024-11-17T07:12:55.000Z","size":160,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-02T17:57:06.583Z","etag":null,"topics":["expressjs","json-schema","nodejs","rest-api","veloze"],"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/commenthol.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-16T05:42:22.000Z","updated_at":"2024-11-17T07:12:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"d3e30f7b-6095-439a-a804-68f1275f3257","html_url":"https://github.com/commenthol/veloze-restbase","commit_stats":null,"previous_names":["commenthol/veloze-restbase"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/commenthol/veloze-restbase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fveloze-restbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fveloze-restbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fveloze-restbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fveloze-restbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commenthol","download_url":"https://codeload.github.com/commenthol/veloze-restbase/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Fveloze-restbase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29314705,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T17:48:59.043Z","status":"ssl_error","status_checked_at":"2026-02-10T17:45:37.240Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["expressjs","json-schema","nodejs","rest-api","veloze"],"created_at":"2024-11-11T11:22:18.199Z","updated_at":"2026-02-10T20:30:55.095Z","avatar_url":"https://github.com/commenthol.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm-badge][npm-badge]][npm]\n![types-badge][types-badge]\n\n# @veloze/restbase\n\n\u003e Rest-API to database using JSON-schema\n\nIn software development we often repeat ourselves when it comes to persisting\ndata. Usually you may just want to store data records according to a model (and\nits schema), which does not necessarily relate to another model.\n\nThis project may help you to define a RESTful Router based on a provided\nJSON-schema. Such schema needs to be \"flat\" such that data can be persisted and\nqueried from relational databases also.\n\nIt implements the common RESTful endpoints for persisting and querying documents\nbased on the documents JSON-schema:\n\n- **C**reate: `POST /{modelName}`\n- **R**ead: `GET /{modelName}/:id`\n- simple find: `GET /{modelName}?:queryParams`\n- complex find: `SEARCH /{modelName}` or `POST /{modelName}/search`\n- **U**pdate: `PUT /{modelName}/:id`\n- **D**elete: `DELETE /{modelName}/:id`\n\nas well as bulk operations on many documents:\n\n- **C**reate many: `POST /{modelName}/create`\n- **U**pdate many: `PUT /{modelName}`\n- **D**elete many: `POST /{modelName}/delete`\n\nProvides database adapters for:\n\n- [mongodb](https://www.mongodb.com/docs/drivers/node/current/)\n- mysql, mysql, postgres, cockroach via [sequelize](https://sequelize.org/)\n\nUses optimistic locking by default. Optionally it allows to defer deletion of\ndocuments (documents are marked for deletion, but are not immediately removed;\nrequires a separate cleanup job).\n\nWorks also with express like routers.\n\nPlease refer to the documentation in [docs/index.md](./docs/index.md).\n\n# Usage\n\n```sh\npnpm i @veloze/restbase\n```\n\n```js\nimport { Server } from \"veloze\";\nimport { MongoClient } from \"mongodb\";\nimport { modelRouter, MongoAdapter } from \"@veloze/restbase\";\n\nconst {\n  HTTP_PORT = 3000,\n  MONGODB_URL = \"mongodb://root:example@127.0.0.1:27017\",\n} = process.env;\n\n// 1. define a JSON-schema\nconst jsonSchema = {\n  type: \"object\",\n  required: [\"item\"],\n  properties: {\n    item: { type: \"string\", maxLength: 255 },\n    quantity: { type: \"integer\", minimum: 0, default: 0 },\n  },\n};\n// 2. create an adapter\nconst client = new MongoClient(MONGODB_URL); // db driver (reuse for multiple data object)\nconst adapter = new MongoAdapter({\n  client,\n  database: \"inventory\",\n  modelName: \"items\", // use plural form!!\n  optimisticLocking: true, // enables optimistic locking (by version `v`)\n  instantDeletion: false,  // disables instant deletion of documents\n  jsonSchema,\n});\n// 3. create the rest-router by passing the adapter\nconst itemsRouter = modelRouter({ adapter });\n// 4. create a Server\nconst server = new Server({ onlyHTTP1: true });\n// 5. mount the router to the \"plural\" path\nserver.use(\"/items\", itemsRouter.handle);\n// 6. start up the server\nserver.listen(HTTP_PORT);\n```\n\nRun the example:\n\n```sh\n# clone this project\ngit clone https://github.com/commenthol/veloze-restbase\n# install dependencies\nnpm i\n```\n\nwith mongodb\n```sh\n# start mongodb (needs docker, docker-compose)\nnpm run dc:up -- mongodb\n# start the server\nnode examples/index.js\n# make some noise\nnode examples/traffic.js\n```\n\nwith postgres\n```sh\n# start postgres (needs docker, docker-compose)\nnpm run dc:up -- postgres\n# start the server\nnode examples/express.js\n# make some noise\nnode examples/traffic.js\n```\n\n# License\n\nMIT licensed\n\n[npm-badge]: https://badgen.net/npm/v/@veloze/restbase\n[npm]: https://www.npmjs.com/package/@veloze/restbase\n[types-badge]: https://badgen.net/npm/types/@veloze/restbase\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Fveloze-restbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommenthol%2Fveloze-restbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Fveloze-restbase/lists"}