econf

1.2.0 • Public • Published

econf

Load configs from hierarchical objects to process.env

NPM version Dependency Status Dependency Status Build Status

NPM NPM

By default econf tries to load .econf.js file

Usage

Import the econf at the top of your code to ensure that your configurations will be loaded before anything else

require('econf')();

optionally, you can specify the file name and custom env name

require('econf')('config.js', 'NODE_ENV');

.econf.js example

module.exports = [
    {
        _name: 'newrelic',
        NEW_RELIC_KEY: 'key'
    },
    {
        _name: 'production',
        NAME: 'Production Base',
        AWS_SECRET: 'aws-secret',
        AWS_KEY: 'aws-key',
        EMAIL_DELAY: 1000
    },
    {
        _name: 'production.001',
        _extend: ['production', 'newrelic'],
        NAME: 'Production 001',
        EMAIL_DELAY: 0
    }
]

.econf.js example as object

module.exports = {
    'newrelic': {
        NEW_RELIC_KEY: 'key'
    },
    'production': {
        NAME: 'Production Base',
        AWS_SECRET: 'aws-secret',
        AWS_KEY: 'aws-key',
        EMAIL_DELAY: 1000
    },
    'production.001': {
        _extend: ['production', 'newrelic'],
        NAME: 'Production 001',
        EMAIL_DELAY: 0
    }
}

The config above will inject the code below into process.env

{
    "_name": "production.001",
    "_extend": [
        "production",
        "newrelic"
    ],
    "NAME": "Production 001",
    "EMAIL_DELAY": 0,
    "AWS_SECRET": "aws-secret",
    "AWS_KEY": "aws-key",
    "NEW_RELIC_KEY": "key"
}

Global Usage

npm install econf -g

With global version you can view your config parsed, just execute econf into your project directory

econf

econf

To create a example .econf.js file into your project just execute econf init into your project directory

econf init

econf

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.2.02latest

Version History

VersionDownloads (Last 7 Days)Published
1.2.02
1.1.00
1.0.01
0.0.30
0.0.23
0.0.11

Package Sidebar

Install

npm i econf

Weekly Downloads

7

Version

1.2.0

License

MIT

Last publish

Collaborators

  • rodrigok