How do i set a variable in app.js and have it be available in all the routes, atleast in the index.js file located in routes. using the express fra
app.js
index.js
A neat way to do this is to use app.locals provided by Express itself. Here is the documentation.
app.locals
// In app.js: app.locals.variable_you_need = 42; // In index.js exports.route = function(req, res){ var variable_i_needed = req.app.locals.variable_you_need; }