rest interface for mongoose models, built on top of express
Mortimer is an extendible REST interface for mongoose models, designed for the entire project lifecycle: from fast prototyping to advanced custom functionality.
|documentation||hosted on coffedoc.info|
|change log||CHANGELOG Releases|
npm install mortimer
var bodyParser = require'body-parser';var express = require'express';var mongoose = require'mongoose';var mortimer = require'mortimer';// Handle connection to mongodb and data modeling.mongooseconnect'mongodb://localhost:27017/examples';var BookSchema ='title': type: String'author': type: String;var Book = mongoosemodel'Book' BookSchema;// Setup http server with express.var app = express;appset'query parser' 'simple';appusebodyParserjson;// Setup mortimer endpoints.var resource = Book;apppost'/books' resourcecreateDoc;appget'/books' resourcereadDocs;appget'/books/count' resourcecountDocs;apppatch'/books' resourcepatchDocs;appdelete'/books' resourceremoveDocs;appget'/books/:bookId' resourcereadDoc;apppatch'/books/:bookId' resourcepatchDoc;appput'/books/:bookId' resourceputDoc;appdelete'/books/:bookId' resourceremoveDoc;// Start the http server onapplisten3000 'localhost';
See more in the
/examples directory. All examples have instructions on how to run and test them.
$ vagrant up
$ npm install
./vagrant_boostrap.shfor instructions on how to setup all dependencies on a fresh ubuntu 14.04 machine.
$ npm run test
$ npm run test.
$ npm run coverageto open a browser window with the coverage report.
$ npm run docto re-generate the documentation.
$ npm run lint
(The MIT License)
Copyright (c) 2012 Alexandru Topliceanu (email@example.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.