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.
all ctrl methods will have access to req.article object through articleID middleware if req.params()
Share this highlighthttp://www.safaribooksonline.com/a/mean-web-development/53576/