Skip to content

Instantly share code, notes, and snippets.

@elado
Last active December 31, 2015 06:29
Show Gist options
  • Save elado/7947979 to your computer and use it in GitHub Desktop.
Save elado/7947979 to your computer and use it in GitHub Desktop.
Simple, multi environment config with Node.js
// app.js
var config = require("config/app");
console.log(config.dbProvider);
// config/app.js
var defaultConfig = {
googleAnalyticsId: "dummy"
};
var _ = require('lodash');
module.exports = _.merge(defaultConfig, require("./" + process.env.NODE_ENV))
// config/envs/development.js
module.exports = {
dbProvider: 'sqlite3'
};
// 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