mortimer = MOngoose ResT
Mortimer is an extendible REST interface for mongoose models, designed for the entire project lifecycle: from fast prototyping to advanced custom functionality.
|change log||CHANGELOG Releases|
- Focus on extensibility. Fully plugable!
- Does not depend on mongoose or express packages. It just builds arrays of middleware functions.
- Easy to bootstrap a basic REST API for your models.
- Supports filtering, pagination, sorting, property selection.
npm install mortimer
var bodyParser = ;var express = ;var mongoose = ;var mortimer = ;// Handle connection to mongodb and data modeling.mongoose;var BookSchema ='title': type: String'author': type: String;var Book = mongoose;// Setup http server with express.var app = ;app;app;// Setup mortimer endpoints.var resource = Book;app;app;app;app;app;app;app;app;app;// Start the http server onapp;
See more in the
/examples directory. All examples have instructions on how to run and test them.
- if you want to quickly bootstrap a rest api, check out this example. You can rapidly define your own routes and let mortimer handle the requests.
- if you want to add middleware in front of every endpoint, check out this example. This can be usefull to add authentication, rate limiting, payload validation, output sanitation, etc. Mortimer is a backbone for all that.
- if you want to add custom functionality to just one middleware, check out this example
- Contributions to this project are more than welcomed!
- Anything from improving docs, code cleanup to advanced functionality is greatly appreciated.
- Before you start working on an ideea, please open an issue and describe in detail what you want to do and why it's important.
- You will get an answer in max 12h depending on your timezone.
- Fork the repo!
- If you use vagrant then simply clone the repo into a folder then issue
$ vagrant up
- if you don't use it, please consider learning it, it's easy to install and to get started with.
- If you don't use it, then you have to:
- install mongodb and have it running on
- install node.js and all node packages required in development using
$ npm install
- For reference, see
./vagrant_boostrap.shfor instructions on how to setup all dependencies on a fresh ubuntu 14.04 machine.
- install mongodb and have it running on
- Run the tests to make sure you have a correct setup:
$ npm run test
- Create a new branch and implement your feature.
- make sure you add tests for your feature. In the end all tests have to pass! To run test suite
$ npm run test.
- make sure test coverage does not decrease. Run
$ npm run coverageto open a browser window with the coverage report.
- make sure you document your code and generated code looks ok. Run
$ npm run docto re-generate the documentation.
- make sure code is linted (and tests too). Run
$ npm run lint
- submit a pull request with your code.
- hit me up for a code review!
- Have my kindest thanks for making this project better!
(The MIT License)
Copyright (c) Alexandru Topliceanu (firstname.lastname@example.org)
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.