Use union type to represent convict schema.

This enables the use of nested config blocks,
which we wasn't possible before.
This commit is contained in:
Jared 2015-01-18 21:48:34 +13:00
parent a283cea01a
commit be72824553
2 changed files with 18 additions and 1 deletions

View File

@ -32,12 +32,29 @@ var conf = convict({
format: (val: string) => validator.isUUID(val),
default: '01527E56-8431-11E4-AF91-47B661C210CA'
},
db: {
ip: {
doc: 'The IP address to bind.',
format: 'ipaddress',
default: '127.0.0.1',
env: 'IP_ADDRESS',
},
port: {
doc: 'The port to bind.',
format: 'port',
default: 0,
env: 'PORT',
arg: 'port',
}
}
});
// load environment dependent configuration
var env = conf.get('env');
var dbip = conf.get('db.ip');
conf.loadFile('./config/' + env + '.json');
conf.loadFile(['./configs/always.json', './configs/sometimes.json']);

View File

@ -8,7 +8,7 @@ declare module "convict" {
module convict {
interface Schema {
[name: string]: {
[name: string]: convict.Schema | {
default: any;
doc?: string;
format?: any;