1.0.4 • Published 5 years ago

@ipdigital/config-loader v1.0.4

Weekly downloads
5
License
ISC
Repository
github
Last release
5 years ago

Config Loader

config-loader, loads your configuration variables for multiple environments.
It allows for more flexibility than using the environment variables due to the support of nested objects.

How it works

config-loader will look for env/default.js in your application's root folder.
Add all the possible variables here and set the default values.
Then it will load env/local.js, continued by env/finally.js. In finally.js you can define some methods to create config variables from previously loaded variables. Config variables are deep-merged and later variables overwrite earlier existing ones.

So default: { a: 0, b: 2 } and local: { a: 1, c: 3 } becomes { a: 1, b: 2, c: 3 }

Install

$ npm install --save env-loader

Usage

require('config-loader');

Config file format

module.exports = {
  "SOME_VAR": "define here",

  "OBJECT": {
	"a": 1,
	"b": 2
  }
};

Example for finally

function manipulate() {
  global.config.url = global.config.host + '/' + global.config.path;
}
module.export = manipulate();
1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago