0.1.1 • Published 8 years ago

naptime v0.1.1

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

#naptime

rest api express middleware for mongoose

npm install --save naptime

#Usage

Define a mongoose schema, and use naptime middleware to provide rest endpoints for that mongoose model. The id is the mongo id returned from the object._id.

import naptime from 'naptime';

const TEST_MODEL = 'Test';

mongoose.model(TEST_MODEL, new mongoose.Schema({
  foo: {
    type: String
  }
}));

const app = express();
app.use('/test', naptime(TEST_MODEL));

// These endpoints will now work

// GET /test
// GET /test/:id
// POST /test
// PUT /test/:id
// DELETE /test/:id