resource-router-middleware
resource-router-middleware copied to clipboard
Authentication
How would you add authentication middleware in this for a specific route? For example only in the put/patch/delete method?
The route handlers can be arrays, you can include an authorization middleware as the first entry in the array and your handler as the second.
I'm also having this problem, @developit can you give an example how it is being done. Something like this?
app.use('/facets', [handlerForPost, handlerForPut], facetResource())
but this isn't effecient as a handler can be different to other resources. :(
+1 for the example
This is what I did and it seems to work:
// read(req, res) {...}
read: [
(req, res, done) => {
console.log("Hello, I'm a middleware");
done();
},
({ resource }, res) => {
res.json(resource);
}
]