How to reference a variable inside a module.exports in Node.js
Just declare it above the module.exports
as an ordinary variable:
var port = '1337';
module.exports = {
port: port,
facebook: {
clientID: '123456789',
clientSecret: 'a1b2c3d4e5f6g7h8i9j0k',
callbackURL: 'http://localhost:'+ port + '/oauth/facebook/callback'
}
};
You can put module.exports
wherever you want in your file, you can even perform some logic (like retrieving settings from a file or another resource).