0.1.0 • Published 8 years ago

nconf-transforms v0.1.0

Weekly downloads
27
License
-
Repository
github
Last release
8 years ago

nconf-transforms

Similar to .NET web.config transforms, nconf-transforms allows you to load nconf configuration files based on convention. By default reads the NODE_ENV environment variable to select what config file to transform. Currently only supports JSON format.

Usage

require('nconf').argv().env() // don't forget to load your environment/argv variables if you want them!

var transform = require('nconf-transforms');

transform({
  dir: './config',
  reload: true // reload nconf when the config file changes
});

where your file tree is something like

/app
  app.js
  /config
    settings.json
    settings.production.json

settings.json

{
  "someConfig": "someValue"
}

app.js

var nconf = require('nconf');
console.log(nconf.get('someConfig')); // "someValue"

API

transform(options)

Loads your base configuration and transforms it using the NODE_ENV environment variable to find the transform file.

Options:

  • dir: String. The directory to find the configuration files. Defaults to __dirname, so set it anyway.
  • fileName: String. The name of your configuration files (i.e settings.json, settings.production.json). Defaults to settings
  • reload: Boolean. Toggles reloading of configuration when the base config changes.
  • environment: String. The environment to transform to. Defaults to process.env['NODE_ENV']

Returns the nconf object so you can chain loading other configuration types/files.

0.1.0

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago