node-restful
node-restful copied to clipboard
Override resource 'index' handler
Hey @baugarten, great work on this lib!
Is there a way to override the handler of specific endpoints on this object? For instance, for listing all of a certain resource i would like to show only a couple of fields and paginating
Thanks! :)
Currently, there's no way to override the handler of specific endpoints.
You can paginate the data manually using the parameters limit=?&skip=?
You can limit the fields by either using an after route or modifying the mongoose schema to make paths not returnable by default.
i.e.
Resource.after('route', function(req, res, next) {
res.locals.bundle = _.omit(res.locals.bundle, 'password', 'secret', 'etc');
next();
});