0.0.18 • Published 9 years ago

x-config v0.0.18

Weekly downloads
21
License
MIT
Repository
github
Last release
9 years ago

Build Status

#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

{
	"id": "my-app",
	"env": { "dev": "^dev", "test": "^test", "prod": "^prod" }, 
	"consoleEnabled": true
}
var config = require('x-config');
if (config.consoleEnabled){
	console.log(config);
}
var configFn = require('x-config'); // returns a function if _rest is enabled.

configFn(function(err, config){
  if (config.consoleEnabled){
    console.log(config);
  }
});

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.

{ "systemConfig": "/etc/node/" }

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.

{ "_rest": { "url": "http://myrestservice/...", "headers": { "X-AuthToken": "auth-token" } } }
0.0.18

9 years ago

0.0.17

9 years ago

0.0.16

9 years ago

0.0.15

9 years ago

0.0.15-beta

9 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago