express-authorize-routes
v1.0.0
Published
Authorize express routes on role based permissions
Downloads
2
Readme
express-authorize-routes
Easily authorize roles based on accesscontrol grants as express middleware.
Usage
import { setGrants, canAccess } from 'express-authorize-routes';
setGrants(YOUR_GRANTS_LIST);
then in then routes do
app.get(
'/',
(req, res, next) => canAccess('admin', 'user', 'read', 'any')(req, res, next),
(req, res, next) => {
console.log('admin can see all the users');
...
},
);
And you are done!