0.0.7 • Published 11 years ago

singleconfig v0.0.7

Weekly downloads
10
License
-
Repository
-
Last release
11 years ago

singleconfig Build Status

=====

singleconfig is a single unified YAML/mustache config for node that can handle environment variables.

With singleconfig you can:

  • Have multiple environments and inheritance in one file (via YAML)
  • Pull in environment variables (via Mustache)

Install

npm install singleconfig

Usage

Let's use this mustache template for a YAML config file (config.yml.mustache)

defaults: &defaults
  port: 5000

development:
  <<: *defaults
  redis:
    url: 'redis://:@localhost:6379/'
  
test:
  <<: *defaults
  port: 3000
  redis:
    url: 'redis://:@localhost:9999/'

production:
  <<: *defaults
  port: {{ env.PORT }}
  redis:
    url: {{ env.REDISTOGO_URL }}

Use your config:

var config = require('singleconfig')('/path/to/my/config.yml.mustache')
console.log(config.port)
console.log(config.redis.url)

Output:

5000
redis://:@localhost:6379/

Change your environment using env variables(defaults to development):

export NODE_ENV='production' 
export PORT=7000
export REDISTOGO_URL=redis://wee:wee@someredistogo.com:9999/

Output (for production):

7000
redis://wee:wee@someredistogo.com:9999/
0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago