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
// don't forget to load your environment/argv variables if you want them! var transform = ; ;
where your file tree is something like
/app
app.js
/config
settings.json
settings.production.json
settings.json
app.js
var nconf = ;console; // "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 tosettings
- 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.