@wesym/config-loader
v1.0.2
Published
Wesym configuration loader
Readme
config-loader
Installation
npm i @wesym/config-loader
Getting started
// index.js
const configLoader = require('@wesym/config-loader')
// Base configuration for dev
configLoader.setBaseConfig('dev', {
HOST: 'localhost',
PORT: 3000,
SOMETHING_FOR_PROD: false
})
// Base configuration for prod
configLoader.setBaseConfig('prod', {
HOST: 'localhost',
PORT: 80,
SOMETHING_FOR_PROD: true
})
// Retrieve the config matching with the NODE_ENV
// and overrides with prefixed env values
console.log(configLoader.getConfig())Examples
# Default dev configuration
> NODE_ENV=dev node .
{
HOST: 'localhost',
PORT: 3000,
SOMETHING_FOR_PROD: false
}# Production configuration with overridden HOST field
> NODE_ENV=prod WESYM_HOST=remote node .
{
HOST: 'remote',
PORT: 80,
SOMETHING_FOR_PROD: true
}