O'Reilly logo
  • Aem A thinks this is interesting:

Fortunately, the Express router provides the app.param() method for handling route parameters. This method allows you to attach a middleware for all requests containing the articleId route parameter. The middleware itself will then use the articleId provided to find the proper MongoDB document and add the retrieved article object to the request object. This will allow all the controller methods that manipulate an existing article to obtain the article object from the Express request object.


Cover of MEAN Web Development


all ctrl methods will have access to req.article object through articleID middleware if req.params()