-
Notifications
You must be signed in to change notification settings - Fork 10
config
Alex Tan Hong Pin edited this page Feb 27, 2017
·
1 revision
Configurations are stored in the environment variables, and will be validated when the server is initialized.
We store the enviroment variables in the .env
file. E.g.
PORT=3000
Validation can be carried out in the config.js
file before exporting
the configs. In this example, we use the library convict
for validating the configs, and setting the defaults if the config is not available in the enviroment variables.
// config.js
import convict from 'convict'
const conf = convict({
port: {
doc: 'The port to bind',
format: 'port',
default: 3000,
env: 'PORT'
}
})
conf.validate({ strict: true })
export default conf