1.0.0 • Published 8 years ago

configa v1.0.0

Weekly downloads
13
License
MIT
Repository
github
Last release
8 years ago

configa

app configuration management for node.js

This is a really simple module. It basically allows you to have a mix of configuration/arguments in the form of CLI arguments, ENV vars, and defaults. The important thing is the priority in case the values are set in multiple ways. The values are returned using the following priority:

  1. CLI Arguments (argv)
  2. ENV Variable (process.env)
  3. Default value

Usage

Installation:

npm install configa

Setup:

var config = require('configa')();

config
  .option({
    name: 'port',
    env: 'PORT',
    alias: 'p', // a cli alias like -p
    type: Number,
    default: 3000
  })
  .option({
    name: 'foo',
    env: 'FOO',
    alias: 'f',
    type: String,
    default: 'bar'
  })
  .option({
    name: 'bar',
    env: 'BAR',
    type: Boolean,
    default: false
  });

And the getter:

var val = config.get('port');

The store() method caches the calculated values for performance:

config
  .option({
    name: 'port',
    env: 'PORT',
    alias: 'p', // a cli alias like -p
    default: 3000
  })
  .store();
1.0.0

8 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