Env config
read config from environment variables.
Install
npm install env-config
Use
given some environment variables:
MY_PROJECT_PORT=8080
MY_PROJECT_MYSQL_USER=foo
MY_PROJECT_MYSQL_PASSWORD=bar
MY_PROJECT_LOG_INFO=true
MY_PROJECT_PROVISION_RATE=0.2
use them in your application:
envConfig = require 'env-config'
specification =
port: 'int'
mysqlUser: 'string'
mysqlPassword: 'string'
logInfo: 'bool'
console.log envConfig 'MY_PROJECT', specification, process.env
# => {
# port: 8080,
# mysqlUser: 'foo',
# mysqlPassword: 'bar',
# logInfo: true
# provisionRate: 0.2
# }
envConfig
throws an exception if an environment variable is empty or can't be converted to the specified type.
License: MIT