Socket
Book a DemoInstallSign in
Socket

koa-rest-mongoose

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-rest-mongoose

mongoose rest generator for koa

2.0.3
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

koa-rest-mongoose

npm Build Status

mongoose rest generator for koa1

NPM

Installation

npm install koa-rest-mongoose

Usage

const koa = require('koa');
const mongoose = require('mongoose');
const KoaRestMongoose = require('koa-rest-mongoose');

// 1 step, mongoose
const mongoUrl = '127.0.0.1:27017/koa_rest_mongoose';
const schema = new mongoose.Schema({
  email: String,
  name: String,
  password: String,
  address: String,
  zipcode: Number,
  lists: Array
});

mongoose.connect(mongoUrl);
mongoose.model('user', schema);

// 2 step, koa and router
const app = koa();
const rest = KoaRestMongoose({
  prefix: '/api'
});
app.use(rest.routes());

// 3 step, done
app.listen(process.env.PORT || 5000);

TODO feature

  • middlewares support

API

Following REST API is now created for you:

HTTP Verb/users/users/:id
GETGet all documents, or documents that match the query.
You can use [mongoose find conditions] (http://mongoosejs.com/docs/queries.html), limit, skip and sort.
For example:
/api/users?conditions={"name":"john"}&limit=10&skip=1&sort=-zipcode
Get the addressed document.
POSTCreate a new document and send it back.Update the addressed document with specified attributes.
PUTCreate a new document and send it back.Replace the addressed document.
DELETEn/aDelete the addressed document.
PATCHn/aUpdate the addressed document with specified attributes.

Keywords

koa

FAQs

Package last updated on 25 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.