I\'m in the process of learning Express - and thinking of the best place to save config style data. Options available are either in app.locals or app.set (settings)... so:
All properties of app.locals
are available in templates. Using app.set
assigns properties to app.locals.settings
, which is used for global application settings and is inherited by mounted applications. For example:
var app1 = express(),
app2 = express();
app1.set('inheritable', 'foo');
app1.locals.notInheritable = 'bar';
app1.use('/mount', app2);
app2.get('inheritable') === 'foo'; // true
app2.locals.notInheritable === 'bar'; // false
So it's really a question of preference and whether or not you're mounting applications.