How to access variables set using app.set() in express js
I know this is 2 years old, but it is still the first link that pops up on google so i thought this could be appropriate.
You could also set your variable like that
app.set('port', 3000);
And later get it with
app.get('port');
I prefer that approach because it's shorter and more straight forward. It is also the way they use in the Express 4.x documentation.
app.get(name)
Returns the value of name app setting, where name is one of strings in the app settings table.
They become available through the app.settings object:
app.set('oneSetting', 'one');
app.set('twoSetting', 'two');
app.set('view engine','jade');
console.log(app.settings.oneSetting);
console.log(app.settings.twoSetting);
console.log(app.settings['view engine']);