I am reviewing an older node project (Typhoon blog engine).
In the route definition module, there are several functions that use the statement req.app.{something}
where {something}
is a function based off of the app
object (i.e. the object created from the deprecated express.createServer()
or the non-deprecated express()
).
I cant find any documentation for express or node that state this object would normally be attached to the request
object. Nor do I see anywhere in the project I am reviewing where req.app
is explicitly defined.
So is the presence of req.app
deprecated behavior for node or express? or is there some deeper magic afoot that I have missed? How is it being done in this project?
edit
When searching the source, I found the following. I still don't see where it is defined, but it does appear to be used in the express request
module.
grep -i -r --exclude-dir=*examples --exclude-dir=*test 'this\.app' ./express
./express/lib/request.js: var trustProxy = this.app.get('trust proxy');
./express/lib/request.js: var trustProxy = this.app.get('trust proxy');
./express/lib/request.js: var offset = this.app.get('subdomain offset');
./express/lib/request.js: var trustProxy = this.app.get('trust proxy');
./express/lib/response.js: var app = this.app;
grep -i -r --exclude-dir=*examples --exclude-dir=*test 'app =' ./express
./express/lib/application.js:var app = exports = module.exports = {};
./express/lib/application.js: if (fn.handle && fn.set) mount_app = fn;
./express/lib/application.js: * , app = express();
./express/lib/response.js: var app = this.app;
./express/lib/response.js: , app = req.app;
./express/lib/express.js: var app = function(req, res, next) {
./express/support/app.js:var app = express()