Skip to content

Instantly share code, notes, and snippets.

@jboxman
Created May 29, 2017 00:12
Show Gist options
  • Save jboxman/134395a97f9b6cc692fb86055796a813 to your computer and use it in GitHub Desktop.
Save jboxman/134395a97f9b6cc692fb86055796a813 to your computer and use it in GitHub Desktop.
Export config based upon process.env.NODE_ENV
// From: https://raw.githubusercontent.com/dozoisch/koa-react-full-example/master/config/config.js
const path = require('path');
const _ = require('lodash');
const env = process.env.NODE_ENV = process.env.NODE_ENV || 'development';
const base = {
app: {
root: path.normalize(path.join(__dirname, '../')),
env: env
}
};
const envs = {
development: {
app: {
port: 3000
},
mongodb: {
url: `mongodb://localhost/db_${env}`
}
},
test: {
app: {
port: 3001
},
mongodb: {
url: `mongodb://localhost/db_${env}`
}
},
production: {
app: {
port: process.env.PORT || 3000
},
mongodb: {
url: `mongodb://localhost/db_${env}`
}
}
};
module.exports = _.merge(base, envs[env]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment