{"id":15780339,"url":"https://github.com/balazs4/rest-flat-file-db","last_synced_at":"2026-05-20T05:34:53.086Z","repository":{"id":57354907,"uuid":"90550312","full_name":"balazs4/rest-flat-file-db","owner":"balazs4","description":"flat-file-db + REST = rest-flat-file-db","archived":false,"fork":false,"pushed_at":"2018-02-11T09:31:41.000Z","size":60,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-09T13:35:29.105Z","etag":null,"topics":["database","db","flat-file-db","lightweight","rest-api"],"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/balazs4.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":"2017-05-07T17:39:24.000Z","updated_at":"2019-03-01T16:01:29.000Z","dependencies_parsed_at":"2022-09-26T16:31:37.186Z","dependency_job_id":null,"html_url":"https://github.com/balazs4/rest-flat-file-db","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/balazs4/rest-flat-file-db","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balazs4%2Frest-flat-file-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balazs4%2Frest-flat-file-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balazs4%2Frest-flat-file-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balazs4%2Frest-flat-file-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/balazs4","download_url":"https://codeload.github.com/balazs4/rest-flat-file-db/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/balazs4%2Frest-flat-file-db/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269986726,"owners_count":24508151,"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-08-11T02:00:10.019Z","response_time":75,"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":["database","db","flat-file-db","lightweight","rest-api"],"created_at":"2024-10-04T18:41:17.092Z","updated_at":"2026-05-20T05:34:48.063Z","avatar_url":"https://github.com/balazs4.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rest-flat-file-db\n\n[![Build Status](https://travis-ci.org/balazs4/rest-flat-file-db.svg?branch=master)](https://travis-ci.org/balazs4/rest-flat-file-db)\n[![dependencies](https://david-dm.org/balazs4/rest-flat-file-db/status.svg)](https://david-dm.org/balazs4/rest-flat-file-db)\n[![devDependencies](https://david-dm.org/balazs4/rest-flat-file-db/dev-status.svg)](https://david-dm.org/balazs4/rest-flat-file-db?type=dev)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbalazs4%2Frest-flat-file-db.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbalazs4%2Frest-flat-file-db?ref=badge_shield)\n\n\u003e REST API for [flat-file-db](https://github.com/mafintosh/flat-file-db) powered by [koa2](https://github.com/koajs/koa)\n\n## About\n\nThis is a tiny module which extends the lightweight `flat-file-db` key-value based `to-go` datastorage.\nIt might be useful for small projects (e.g. hackathon).\n\n## Usage\n\n### As standalone instance\n\n```\n# install the module globally\n$ npm install -g rest-flat-file-db\n\n# start the module with default parameters\n$ rest-flat\n\n# OR start it with custom parameters\n$ PORT=3333 DB=/tmp/mydatabase rest-flat\n```\n\n### As module\n\n`$ npm install rest-flat-file-db --save`\n\n\n```javascript\n\n// index.js\n\nconst restflat = require('rest-flat-file-db');\nconst flatdb = require('flat-file-db');\n\nconst app = restflat(flatdb.sync('/tmp/mydatabase'));\n\n// this is just a normal koa2 app and it is ready to launch.\n\napp.listen();\n\n```\n\n**Hint**: You can pass your own `koa` app as well if you want to make some setup on it before the rest-flat endpoints will be initialized. (e.g. Authentication)\nThis second parameter is optional. In default case the `koa` instance  will be created by the `rest-flat-file-db` itself.\n\n\n## REST API\n\n#### GET /\n\n200 and a single object contains all key-value pairs of the database\n\n#### GET /:key\n\n200 (if the `key` could be found, otherwise 404) and the value of :key\n\n#### POST /:key\n\n409 if `key` already exists in the database otherwise 201 and the body of the post will be stored with the `key` in the db (response.headers['location'] contains the url to the item)\n\n#### PUT /:key\n\n200 (if the `key` could be found, otherwise 404) and the **updated** item with its new content\n\n#### PATCH /:key\n\n200 (if the `key` could be found, otherwise 404) and the **merged** (with `Object.assign` call) item with its new content\n\n#### DELETE /:key\n\n200 (if the `key` could be found, otherwise 404) and the **deleted** item from the db (it acts like a `pop` call on a stack)\n\n#### POST /\n\n201 and the body of the post will be stored with a **generated** key in the db (response.headers['location'] contains the url to the item)\n\n\n## License\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbalazs4%2Frest-flat-file-db.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbalazs4%2Frest-flat-file-db?ref=badge_large)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbalazs4%2Frest-flat-file-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbalazs4%2Frest-flat-file-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbalazs4%2Frest-flat-file-db/lists"}