O'Reilly logo
  • Patrick S thinks this is interesting:

The following is an example of plugging param middleware into an app that has a Mongoskin/Monk-like database connection in req.db:

app.param('id', function(request, response, next, id){
  req.db.get('stories').findOne({_id: id}, function (error, story){
    if (error) return next(error);
    if (!story) return next(new Error('Nothing is found'));
    req.story = story;
    next();
&...

From

Cover of Pro Express.js

Note

param middleware example