I have an express.js file which requires config.js which loads development.js. Now I want to use secret as a variable in session object of express-session. I will give you a quick breakup of how I had setup my code so far.
Config folder
Env
-- development.js
-- config.js
-- express.js
Development.js
module.exports = function(){
sessionSecret: 'developmentSessionSecret'
}
Config.js
module.exports = require('./env/' + process.env.NODE_ENV + '.js' );
** Express.js **
var config = require('./config'),
session = require('express-session');
app.use(session({
saveUninitialized: true,
resave: true,
secret: config.sessionSecret
}));
The problem is that console.log(config.sessionSecret) is undefined. Why this is not working and what will be the correct way to set up ?