ngYamlConfig v0.1.1
ngYamlConfig
Write your configuration files for node.js in yaml
Installation
npm install ngYamlConfig
Usage
var yaml_config = require('ngYamlConfig');
var config = yaml_config.load(__dirname + '/config/config.yml');
console.log(config);
Configuration Files
In your configuration file:
default:
server:
port: 3000
database:
host: 'localhost'
port: 27017
development:
database:
db: 'dev_db'
test:
database:
db: 'test_db'
production:
server:
port: 8000
database:
db: 'prod_db'
user: 'dbuser'
password: 'pass'
cache:
dir: 'static'
ngYamlConfig takes the configuration found in default, then overwrites it with the values found in the environment specific parts. The configuration file is loaded synchronously.
API
load(filename, env)
Load the configuration found in filename
with the environment based on NODE_ENV
. The environment can be forced with the env
argument.
ngYamlConfig keeps parsed yaml files in memory to avoid reading files again.
reload(filename)
Reload the configuration found in filename
. Later calls to load
will show the new configuration.
The file is loaded synchronously.
###getEnvironmentParameter(filename, environment, parameterName)
Returns a json key-value with the parameter name and value
###getEnvironmentParameters(filename, environment)
Returns a json object that contains all of the parameters of the given object