You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

econf

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

econf

Load configs from hierarchical objects to process.env

1.2.0
latest
Source
npm
Version published
Weekly downloads
12
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 09 Apr 2014

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