Is it common for Express plugins/third-party modules to add properties or functions to the req, res, and app objects?

12 views
Skip to first unread message

Behrang Saeedzadeh

unread,
Aug 23, 2015, 12:20:49 AM8/23/15
to Express
Hi,

For example, Swagger Node adds a property named swagger to the req object:

function hello(req, res) {
    var name = req.swagger.params.name.value || 'stranger';
    var hello = util.format('Hello, %s', name);
    res.json(hello);
}

If this is common and conventional, what guidelines should I follow to make sure my plugin/middleware does not clash with another plugins injected properties or properties that might be added to req, res, and app objects in upcoming Swagger releases?

Thanks,
Behrang
Reply all
Reply to author
Forward
0 new messages