Quantcast
Channel: Apply middleware to route in Express - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Apply middleware to route in Express

$
0
0

I would like to apply a middleware to a route regardless of the type of request. Currently I have:

router.route('/campaigns')    .get(restrictTo('advertiser'), restrictTo('admin'), queries.getCampaigns)    .post(restrictTo('advertiser'), restrictTo('admin'), queries.createCampaign);

And I would like something like:

router.route('/campaigns', restrictTo('advertiser'), restrictTo('admin'))    .get(queries.getCampaigns)    .post(queries.createCampaign);

But this does not seem to work.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images