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
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Opinionated configuration management module for Node.js daemon applications.
--config=/etc/app.toml
wild-config tries to load configuration in the following order (missing files are skipped, except the one provided by --config
argument). Values are merged.
--config
or -c
argument valueIf you want to use a different configuration directory than './config' for default configuration files, then set it with the
NODE_CONFIG_DIR
environment variable
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.
wild-config toml includes additional options when working with toml
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
{ENV}
is replaced in all file paths by the NODE_ENV valueIf 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
t config = require('wild-config');
ole.log(config.server.enabled);
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);
--config
does not override root.config
value (if it even exists). This argument is used only for defining the configuration file path.MIT