express-crud-router icon indicating copy to clipboard operation
express-crud-router copied to clipboard

Adding a middleware function before sequelize call

Open wattry opened this issue 2 years ago • 1 comments

Hi there

I was wondering if you've thought about adding an option to allow users to provide a middleware function. For instance a permission check on a given route.

import authCheck from './authCheck';
const ROLES = ['ROLE_1', 'ROLE_2']

express.Router()
    .get('/some/resource', authCheck(ROLES), (req, res, next) => {})

As far as I can see there is no ability to add any validator or permission-checking middleware.

wattry avatar Aug 19 '22 14:08 wattry

Hello @wattry. Sorry for the delay to answer. I am now maintaining this library and I share your concern. Do you have any suggestion of what the API should looks like?

nicgirault avatar Aug 19 '23 14:08 nicgirault