nap-service
v0.1.3
Published
Node API Provider is a highly-configurable express API provider based on mongoose that support authentification and roles
Readme
Nap
The highly-configurable RESTful HTTP service provider made for Express framework and Mongoose
Using it
var nap = require('nap');
api = nap(globalOptions);
api.add(modelObject);
api.inject(app);globalOptions
[ ]
authGroups: an array containing all the different groups, ordered for a waterfall (last groups inherits the first group autorizations) (ex: `['guest'])[ ]
getRole: a function called wth two arguments,userIdthe id string, number or object corresponding to the current logged user andcallbacka function to be called with a string corresponding to the user role[ ]
canThis: overrides the canThis middleware. Injected athisobject:configthe passed configgetRole()a Promise that wraps thegetRolespecified optiondeny()call it to deny accessallow()the accessurlcurrent urlparamsthe request paramsmethodthe HTTP method
modelObject
- [ ]
modelthe model name or object - [ ]
authorizationsan object where the value is the method (GET, PUT...) and the value an array of user roles (cascading). Example:get: ["guest"]everybody, from guests to admins will be able to GETpost: ["user"]only logged users or admins will be able to POSTput: ["admin"]only admin will be able to do this
- [ ]
authorshipused when a user PUT his own mod he might be able to edit it even though he doesn't have the PUT authorization (see above). This is the name of the field that contains the author id. - [ ]
indexFieldsthe fields selected onGET /{model} - [ ]
dontBreakdon't put the selected fields as a new model

