Ways to define the variables. (Example defines DEBUG and TEST flags)
directly in the configuration
// foo.yml
debug: true
test: true
from the command line:
> node index --debug --test
using environment configuration(comma delimited)
> set ENV=DEBUG,TEST
# also
> set NODE_ENV=DEBUG,TEST
> node index
.toJSON():Object
Returns clean json configuration object.
.done(callback)
Fire the callback when the configuration is loaded
Source
Common properties for all source types
{
// Define specific property to extract SUB-JSON from the loaded configuration
// @default: null
getterProperty: String
// Define specific property in the root configuration,
// where the loaded configuration should be inserted into
// @default: null
setterProperty: String
// Specify if this source can be used for persistence
// @default: false
writable: Boolean
// Fires before source $read function is called
// (e.g. change this.path property or any other things)
beforeRead: Function<Source, RootConfig>
// Fires after source completes reading
// (e.g. access config object in `Source.config`)
afterRead: Function<Source, RootConfig>
// If true, do not log any warning if the source returns 404
// @default: false
optional: true
// If true, then waits until all previous sources are loaded
// @default: false
sync: true
}
FileSource
{
// File path
path: String
}
DirectorySource
It will be mapped to multiple FileSources
{
// Directory path with GLOB look-up, e.g. 'configs/**.json'
path: String
}
MongoDBSource
Depends on ClassJS
{
// Collection name
mongo: String,
// if source is writable
// @default: true
writable: Boolean
// MongoDB Connection Settings
// It can be also specified in previous configuration source, under `mongodb` property
// @default: null -
settings: {
// connection string
connection: String
// or
// Port, default 27017
port: Number,
// IP, default '127.0.0.1'
ip: String,
// Database name, no default
db: String
}
}
CustomSource
This source type can suit any needs.
// Constructor with the Deferrable Interface and the method `read`
Function
// e.g. using ClassJS
Class({
Base: Class.Deferred,
read: function(){
// do any reads and calcs, after that resolve the source
this.config = fooConfig();
this.resolve();
}
})