env-config

env-config reads configuration for twelve-factor-apps from environment variables

Env Config

read configuration from environment variables.

npm install https://github.com/snd/env-config.git
envConfig = require 'env-config'
 
specification =
    port: 'int'
    mysqlUser: 'string'
    mysqlPassword: 'string'
    logInfo: 'bool'
 
environment =
    PROJECT_NAME_PORT: '8080'
    PROJECT_NAME_MYSQL_USER: 'foo'
    PROJECT_NAME_MYSQL_PASSWORD: 'bar'
    PROJECT_NAME_LOG_INFO: 'true'
 
config = envConfig 'PROJECT_NAME_'specificationenvironment
 
console.log config
 
# =>  { 
#       port: 8080, 
#       mysqlUser: 'foo', 
#       mysqlPassword: 'bar', 
#       logInfo: true  
#   } 

MIT