1.0.0 • Published 4 years ago

express-authorize-routes v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

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!