x-config
This package provides an easy way to access configuration information based on local or system configuration files. This package follows the following inheritance flow:
- ./config/default.json
- ./config/{{environment}}.json
- {{system}}/{{id}}.json
- {{system}}/default.json
NOTES:
- The locator climbs the path from the parent module location to the volume root looking for a config directory. This enables packages to maintain seperate configurations.
- The environment can be determined via HOSTNAME, or by placing env in default.json with dev, test, or prod, or pattern matching (see below).
Usage
npm install x-config --save
var config = ;if configconsoleEnabled console;
var configFn = ; // returns a function if _rest is enabled. ;
The path to the system configuration files can either be defined using a SYSTEM_CONFIG environment variable or set systemConfig in the default or environment config files.
To pull configuration from a REST service, use the following. This will cause the config library to return a function which you will want to call.