0.2.0 • Published 8 years ago
ms-amqp-conf v0.2.0
Configuration loading module
Combines dotenv, nconf and processes env configuration into camelcase; Each value is JSON parsed first if it is possible, therefore you can pass arrays/objects and boolean params through env
Installation
npm i ms-amqp-conf -S
Configuration
Accepts following configuration params, which can be passed through .env
or process.env
DOTENV_NOT_SILENT
- if present, warnings from dotenv wont be supressedDOTENV_ENCODING
- defaults to 'utf-8'DOTENV_FILE_PATH
- if .env file isn't located in the root of your module, you can pass path hereNCONF_SEPARATOR
- defaults to__
NCONF_MATCH
- only envs, matched by this would be returned through configurationNCONF_MATCH_OPTS
- opts for regexp constructed fromNCONF_MATCH
NCONF_WHITELIST
- stringified JSON array of variebles that should be parsed into final configurationNCONF_FILE_PATH
- external JSON configuration file that will be used to provide variablesNCONF_NAMESPACE
- MUST be specified, as it will return configuration relative to this namespaceNCONF_NO_CAMELCASE
- if present, keys will not be camelCased
Usage
.env
file:
NCONF_NAMESPACE=MS_CONF
NCONF_MATCH=^MS_CONF
NCONF_MATCH_OPTS=i
MS_CONF__AMQP__HOSTS=["127.0.0.1"]
MS_CONF__AMQP__SSL=true
MS_CONF__AMQP__STRING_TRUE='"true"'
const config = require('ms-amqp-conf');
// config would equal
// {
// amqp: {
// hosts: [ '127.0.0.1' ],
// ssl: true,
// stringTrue: 'true'
// }
// }
For a more detailed example - see tests