How to get access to custom object express application in all templates?

I have a simple nodejs express aplication. How to get access to custom object ( for example req or res ) in all templates ?

For example :

exports.test = function (req, res) {
        res.render('test', { 'req' : req });
    }

return object req for location/template test. Ho to do it for ALL locations/templates without duplication code ?

You could do it in a custom middleware somewhere up in your middleware/route stack:

app.use(function(req, res, next) {
  res.locals.req = req;
  next();
});