Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Mar 17, 2024 via pnpm

config-chain 1.1.13

HANDLE CONFIGURATION ONCE AND FOR ALL
Package summary
Share
0
issues
2
licenses
2
ISC
1
MIT
Package created
5 Nov 2011
Version published
3 Jun 2021
Maintainers
2
Total deps
3
Direct deps
2
License
MIT

Issues

0
This package has no issues

Licenses

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
ini@1.3.8
proto-list@1.2.4

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
config-chain@1.1.13
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

2
All Dependencies CSV
β“˜ This is a list of config-chain 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
ini1.3.83.9 kBISC
prod
proto-list1.2.42.04 kBISC
prod

Visualizations

Frequently Asked Questions

What does config-chain do?

Config-chain is a powerful JavaScript module specially designed to handle custom configurations in your applications. Its functionalities enable you to define, process, and manage your configuration setup in a flexible and efficient way. This library is particularly useful for applications that require sophisticated configuration management, offering a variety of options for defining and overriding your settings. Despite being frozen, which means there will be no new features added, config-chain remains stable and highly valuable in instances where npm depends on it.

How do you use config-chain?

Utilizing config-chain in your JavaScript code is straightforward, after installing it via npm or yarn. Below is a simplified usage example:

const cc = require('config-chain');

console.log(cc.env('TERM_', process.env));
/*
{ SESSION_ID: 'w1:5F38',
  PROGRAM_VERSION: '3.1.2',
  PROGRAM: 'iTerm.app' }
*/

Here, the cc.env function fetches all keys from the given object (process.env in this case), which have a specific prefix (in this case "TERM_"). Next, it removes this prefix and assigns the values to a new object.

For a more elaborate use case, you can manage multiple configuration layers and set precedence, here's how:

var cc = require('config-chain')
var conf =cc(
    // Command line options
    opts,
    // Environment variables with 'myApp_' prefix
    cc.env('myApp_'),
    // Config file named by environment
    path.join(__dirname,  'config.' + env + '.json'),
    // If `env` is 'prod', load a special.json file
    env === 'prod' ? path.join(__dirname, 'special.json') : null,
    // Nested directory config
    path.join(__dirname,  'config', env, 'config.json'),
    // Search parent directories for a specific file
    cc.find('config.json'),
    // Defaults
    {
      host: 'localhost',
      port: 8000
    }
)

var host = conf.get('host');

The Config-chain package allows you to harness the power of layered configurations to ensure your application adapts seamlessly to various environments and conditions.

Where are the config-chain docs?

The comprehensive documentation for config-chain can be found within the GitHub repository README file, providing an overview of its use, examples showing how to implement it, as well as detailed explanations of its APIs and methods. This great resource will steer you through the process of initializing config-chain, setting and getting configuration values, loading configuration from files, URLs, environment variables and other sources, and handling configuration errors. With these detailed instructions and explanations, you will be well-equipped to leverage the full potential and versatility of the config-chain package in your projects.