{"id":18324317,"url":"https://github.com/luoyjx/koa-rest-mongoose","last_synced_at":"2025-07-12T07:34:51.093Z","repository":{"id":91027859,"uuid":"66849989","full_name":"luoyjx/koa-rest-mongoose","owner":"luoyjx","description":"mongoose rest api generator for koa","archived":false,"fork":false,"pushed_at":"2017-05-25T02:28:09.000Z","size":24,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-12T07:34:48.750Z","etag":null,"topics":["koa","mongoose","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luoyjx.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-29T14:16:06.000Z","updated_at":"2017-11-26T01:41:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"293663fc-4236-415b-bb8f-17b2f6e58b1d","html_url":"https://github.com/luoyjx/koa-rest-mongoose","commit_stats":{"total_commits":35,"total_committers":1,"mean_commits":35.0,"dds":0.0,"last_synced_commit":"322e4b6623ff0f708df383c7dd76bee76e90be81"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/luoyjx/koa-rest-mongoose","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luoyjx%2Fkoa-rest-mongoose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luoyjx%2Fkoa-rest-mongoose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luoyjx%2Fkoa-rest-mongoose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luoyjx%2Fkoa-rest-mongoose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luoyjx","download_url":"https://codeload.github.com/luoyjx/koa-rest-mongoose/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luoyjx%2Fkoa-rest-mongoose/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264958196,"owners_count":23689011,"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":["koa","mongoose","rest-api"],"created_at":"2024-11-05T18:33:45.097Z","updated_at":"2025-07-12T07:34:51.055Z","avatar_url":"https://github.com/luoyjx.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# koa-rest-mongoose \n\n[![npm](https://img.shields.io/npm/v/koa-rest-mongoose.svg)](https://www.npmjs.com/package/koa-rest-mongoose) [![Build Status](https://travis-ci.org/luoyjx/koa-rest-mongoose.svg?branch=master)](https://travis-ci.org/luoyjx/koa-rest-mongoose)\n\nmongoose rest generator for koa1\n\n[![NPM](https://nodei.co/npm/koa-rest-mongoose.png?downloads=true)](https://nodei.co/npm/koa-rest-mongoose/)\n\n# Installation\n\n```shell\nnpm install koa-rest-mongoose\n```\n\n# Usage\n\n```javascript\nconst koa = require('koa');\nconst mongoose = require('mongoose');\nconst KoaRestMongoose = require('koa-rest-mongoose');\n\n// 1 step, mongoose\nconst mongoUrl = '127.0.0.1:27017/koa_rest_mongoose';\nconst schema = new mongoose.Schema({\n  email: String,\n  name: String,\n  password: String,\n  address: String,\n  zipcode: Number,\n  lists: Array\n});\n\nmongoose.connect(mongoUrl);\nmongoose.model('user', schema);\n\n// 2 step, koa and router\nconst app = koa();\nconst rest = KoaRestMongoose({\n  prefix: '/api'\n});\napp.use(rest.routes());\n\n// 3 step, done\napp.listen(process.env.PORT || 5000);\n```\n# TODO feature\n\n- [ ] middlewares support\n\n# API\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. |","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluoyjx%2Fkoa-rest-mongoose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluoyjx%2Fkoa-rest-mongoose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluoyjx%2Fkoa-rest-mongoose/lists"}