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.
// Scaffold all your REST API with one line of codeoExpressRouter 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 version: '1.0' // Base uri endpoint uri: '/' // Database adapter for CRUD middleware adapter: 'mongoose' // OR "sequelize" for SQL database support // Default limit limit: 10 // Entities and allowed fields scope entities: "users": // Endpoint URI endpoint: 'users' // Cannot read other users user_restricted: field: '_id' 'GET': true 'POST': true 'PUT': true 'DELETE': true // Readable attributes scope (other will be hidden and immutable) fields: "_id" "username" "email" "provider" "profile" "token" "created"
Test
Run "npm test" directly in the project folder.
Documentation
Currently at work.
Contribute
Coming soon