nodemailer/wild-config

Name: wild-config

Owner: nodemailer

Description: Application configuration management module

Created: 2017-07-16 07:20:43.0

Updated: 2018-01-02 08:53:44.0

Pushed: 2017-10-26 07:20:16.0

Homepage: null

Size: 17

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

wild-config

Opinionated configuration management module for Node.js daemon applications.

Loading order

wild-config tries to load configuration in the following order (missing files are skipped, except the one provided by --config argument). Values are merged.

  1. ./config/default.*
  2. ./config/$NODE_ENV.*
  3. --config or -c argument value
  4. command line arguments

If you want to use a different configuration directory than './config' for default configuration files, then set it with the NODE_CONFIG_DIR environment variable

Command line arguments

When using command line arguments to provide config values only such keys are merged that already exist in the configuration object. For subkeys use dot notation. Value type (numbers, booleans and strings are supported) is defined by existing value.

Example config/default.toml:

ver]
led=false

Override server.enabled value with the following command line argument:

 app.js --server.enabled=true

server.enabled is defined as a boolean in the config file, so the overriden value is also going to be true as a boolean and not "true" as a string.

TOML extensions

wild-config toml includes additional options when working with toml

Including child files

Use the following syntax to include an additional config file in the place of the directive

nclude "/path/to/sub/config.toml"

This directive also works in a nested object

ted]
# @include "/path/to/sub/config.toml"

You can also use wildcards to load data from multiple files

nclude "/path/to/sub/*.toml"
nclude "/path/to/sub/**/*.toml"

Notes

Application config file

If you are running your app as a service daemon, then you can load configuration from a config file by using the --config argument. These values are loaded and merged with the default values.

vice]
ingDirectory=/opt/app
Start=/usr/bin/node index.js --config=/etc/app.toml
Usage
t config = require('wild-config');
ole.log(config.server.enabled);
Configuration reload

wild-config catches SIGHUP signal and reloads configuration files. Additionally a 'reload' event is emitted.

t config = require('wild-config');
ig.on('reload', ()=>{
console.log('New "server.enabled" value: %s', config.server.enabled);

Events
Limitations
Licese

MIT


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.