Last active
December 31, 2015 06:29
-
-
Save elado/7947979 to your computer and use it in GitHub Desktop.
Simple, multi environment config with Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app.js | |
var config = require("config/app"); | |
console.log(config.dbProvider); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// config/app.js | |
var defaultConfig = { | |
googleAnalyticsId: "dummy" | |
}; | |
var _ = require('lodash'); | |
module.exports = _.merge(defaultConfig, require("./" + process.env.NODE_ENV)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// config/envs/development.js | |
module.exports = { | |
dbProvider: 'sqlite3' | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// config/envs/production.js | |
module.exports = { | |
dbProvider: 'pg', | |
googleAnalyticsId: "1234567" | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment