{"id":14975680,"url":"https://github.com/duyet/koa-mongodb-rest","last_synced_at":"2026-02-17T19:03:01.047Z","repository":{"id":51487498,"uuid":"51197552","full_name":"duyet/koa-mongodb-rest","owner":"duyet","description":"Rest API generation for Koa","archived":false,"fork":false,"pushed_at":"2023-12-15T14:54:14.000Z","size":32,"stargazers_count":2,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-19T08:56:20.803Z","etag":null,"topics":[],"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/duyet.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-06T09:57:29.000Z","updated_at":"2020-05-12T18:00:44.000Z","dependencies_parsed_at":"2025-02-10T02:33:05.372Z","dependency_job_id":"cf9a6bdd-f883-430a-8933-cd185046cae1","html_url":"https://github.com/duyet/koa-mongodb-rest","commit_stats":null,"previous_names":["duyetdev/koa-mongodb-rest"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/duyet/koa-mongodb-rest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duyet%2Fkoa-mongodb-rest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duyet%2Fkoa-mongodb-rest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duyet%2Fkoa-mongodb-rest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duyet%2Fkoa-mongodb-rest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duyet","download_url":"https://codeload.github.com/duyet/koa-mongodb-rest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duyet%2Fkoa-mongodb-rest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29554446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T18:16:07.221Z","status":"ssl_error","status_checked_at":"2026-02-17T18:16:04.782Z","response_time":100,"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":[],"created_at":"2024-09-24T13:52:23.002Z","updated_at":"2026-02-17T19:03:01.031Z","avatar_url":"https://github.com/duyet.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Koa mongo REST [![NPM version](https://badge.fury.io/js/koa-mongodb-rest.svg)]\n\nEasy REST api for [koa](http://koajs.com) server  \n\n[![NPM](https://nodei.co/npm/koa-mongodb-rest.png?downloads=true)](https://nodei.co/npm/koa-mongodb-rest/)\n\n\n\n## Installation\nInstall using npm:\n```sh\nnpm install koa-mongodb-rest\n```\n\n## Usage\n\nRequire library\n```javascript\ngenerateApi = require('koa-mongodb-rest');\n```\n\nCreate mongoose model\n```javascript\nmongoose = require('mongoose');\nmongoose.connect('mongodb://127.0.0.1/db');\n\nschema = new mongoose.Schema({\n  email: String,\n  name: String,\n  password: String,\n  address: String,\n  zipcode: Number,\n  lists: Array\n});\n\nmodel = mongoose.model('users', schema);\n```\n\nCreate server\n```javascript\nvar koa = require('koa');\nvar route = require('koa-route');\n\nvar app = koa();\n\n//router is required\napp.use(router(app));\n\n\n//add REST routes to your app. Prefix is optional\ngenerateApi(app, route, model, '/api');\n\napp.listen(process.env.PORT || 5000);\n```\n\nFollowing REST API is now created for you:\n\n| HTTP Verb     | /users   | /users/:id |\n| ------------- | ------------- | --------------- |\n| GET           | Get all documents, or documents that match the query. \u003cbr\u003e You can use [mongoose find conditions] (http://mongoosejs.com/docs/queries.html), limit, skip and sort. \u003cbr\u003e For example: \u003cbr\u003e **/api/users?conditions={\"name\":\"john\"}\u0026limit=10\u0026skip=1\u0026sort=-zipcode** | Get the addressed document. |\n| POST          | Create a new document and send it back. |  Update the addressed document with specified attributes. |\n| PUT           | Create a new document and send it back. | Replace the addressed document. |\n| DELETE        | n/a | Delete the addressed document. |\n| PATCH         | n/a | Update the addressed document with specified attributes. |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduyet%2Fkoa-mongodb-rest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduyet%2Fkoa-mongodb-rest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduyet%2Fkoa-mongodb-rest/lists"}