The highly-configurable RESTful HTTP service provider made for Express framework and Mongoose
var nap = require('nap');
api = nap(globalOptions);
api.add(modelObject);
api.inject(app);
-
authGroups
: an array containing all the different groups, ordered for waterfall (last groups inherits the first group autorizations) (ex: `['guest']) -
getRole
: a function called wth two arguments,userId
the id string, number or object corresponding to the current logged user andcallback
a function to be called with a string corresponding to the user role -
canThis
: overrides the canThis middleware. Injected athis
object:config
the passed configgetRole()
a Promise that wraps thegetRole
specified optiondeny()
call it to deny accessallow()
the accessurl
current urlparams
the request paramsmethod
the HTTP method
-
model
the model name or object -
authorizations
an 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
-
authorship
used 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. -
indexFields
the fields selected onGET /{model}
-
dontBreak
don't put the selected fields as a new model