Created
May 29, 2017 00:12
-
-
Save jboxman/134395a97f9b6cc692fb86055796a813 to your computer and use it in GitHub Desktop.
Export config based upon 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
// 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