node-rest
REST API implementation in Javascript with NodeJS and Express. Built on top of Mongoose and Sequelize ORM.
Out of the box features
- Plug and play REST API
- RESTful API endpoints scaffolded from any database table or document schema
- Life cycle events hooks (pre/post load/persist/update/delete)
- Generic CRUD middleware with support for relational and non relational databases
- Role based ACL management system
- Users scope restrictions on any API endpoint with the " user_restricted" option
- Restrict any API resource attributes scope
Installation
npm i nbo-rest -S
Getting started
Using ExpressJS add this line inside your default controller.
new rest(oExpressRouter, oAuthMiddleWare, oApiConfig);
The first parameter is your Express router, the second is your auth middleware for your endpoints that need authentication, and the last one is your API configuration, here's an example:
{
version: '1.0',
uri: '/',
adapter: 'mongoose',
limit: 10,
entities: {
"users": {
endpoint: 'users',
user_restricted: { field: '_id', 'GET': true, 'POST': true, 'PUT': true, 'DELETE': true },
fields: ["_id", "username", "email", "provider", "profile", "token", "created"]
}
}
}
Test
Run "npm test" directly in the project folder.
Documentation
Currently at work.
Contribute
Coming soon