Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wild-config

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wild-config

Configuration management module

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
519
decreased by-3.89%
Maintainers
1
Weekly downloads
 
Created
Source

wild-config

Opinionated configuration management module for Node.js daemon applications.

wild-config loads configuration from application config directory and from a config path if provided. All configuration files use toml syntax.

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.toml
  2. ./config/$NODE_ENV.toml
  3. --config or -c argument value
  4. command line arguments
Command line arguments

In case of command line arguments 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 default.toml

[server]
enabled=false

Override server.enabled with the following command line:

node app.js --server.enabled=true
Application config file

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

[Service]
WorkingDirectory=/opt/application
ExecStart=/usr/bin/node index.js --config=/etc/app.toml

Usage

const config = require('wild-config');

console.log(config.server.enabled); // false

Configuration reload

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

const config = require('wild-config');
config.on('reload', ()=>{
    console.log('Configuration was updated');
    console.log('New "server.enabled" value: %s', config.server.enabled);
});

Events

  • 'reload' emitted when SIGHUP is received

Limitations

  • You can not use "on" as a root key. If you do then it is ignored. This key is reserved for the event emitter handler.

Licese

MIT

Keywords

FAQs

Package last updated on 16 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc