1.2.0 • Published 10 years ago

econf v1.2.0

Weekly downloads
8
License
MIT
Repository
github
Last release
10 years ago

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

1.2.0

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago