Skip to content

Instantly share code, notes, and snippets.

@sagar-gavhane
Created July 22, 2018 15:06
Show Gist options
  • Save sagar-gavhane/0e65c087949bcbb5bb24ffe9a3951723 to your computer and use it in GitHub Desktop.
Save sagar-gavhane/0e65c087949bcbb5bb24ffe9a3951723 to your computer and use it in GitHub Desktop.
environment-dependent-node-js-configuration
// var config = require('./config.js').get(process.env.NODE_ENV);
var config = {
production: {
session: {
key: 'the.express.session.id',
secret: 'something.super.secret'
},
database: 'mongodb://<user>:<pwd>@apollo.modulusmongo.net:27017/db',
twitter: {
consumerKey: 'consumer Key',
consumerSecret: 'consumer Secret',
callbackURL: 'http://yoururl.com/auth/twitter/callback'
}
},
default: {
session: {
key: 'the.express.session.id',
secret: 'something.super.secret'
},
database: 'mongodb://127.0.0.1:27017/db',
twitter: {
consumerKey: 'consumer Key',
consumerSecret: 'consumer Secret',
callbackURL: 'http://127.0.0.1:3000/auth/twitter/callback'
}
}
}
exports.get = function get(env) {
return config[env] || config.default;
}
// Ref: https://medium.com/node-and-beyond/environment-dependent-node-js-configuration-b51149286e7e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment