forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
convict.d.ts
77 lines (70 loc) · 2.71 KB
/
convict.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Type definitions for node-convict v0.6.0
// Project: https://github.com/mozilla/node-convict
// Definitions by: Wim Looman <https://github.com/Nemo157>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "convict" {
module convict {
interface Format {
name?: string;
validate?: (val: any) => void;
coerce?: (val: any) => any;
}
interface Schema {
[name: string]: convict.Schema | {
default: any;
doc?: string;
/**
* From the implementation:
*
* format can be a:
* - predefine type, as seen below
* - an array of enumerated values, e.g. ["production", "development", "testing"]
* - built-in JavaScript type, i.e. Object, Array, String, Number, Boolean
* - or if omitted, the Object.prototype.toString.call of the default value
*
* The docs also state that any function that validates is ok too
*/
format?: string | Array<any> | Function;
env?: string;
arg?: string;
};
}
interface Config {
get(name: string): any;
default(name: string): any;
has(name: string): boolean;
set(name: string, value: any): void;
load(conf: Object): void;
loadFile(file: string): void;
loadFile(files: string[]): void;
validate(): void;
/**
* Exports all the properties (that is the keys and their current values) as a {JSON} {Object}
* @returns {Object} A {JSON} compliant {Object}
*/
getProperties() : Object;
/**
* Exports the schema as a {JSON} {Object}
* @returns {Object} A {JSON} compliant {Object}
*/
getSchema() : Object;
/**
* Exports all the properties (that is the keys and their current values) as a JSON string.
* @returns {String} a string representing this object
*/
toString() : string;
/**
* Exports the schema as a JSON string.
* @returns {String} a string representing the schema of this {Config}
*/
getSchemaString() : string;
}
}
interface convict {
addFormat(format: convict.Format): void;
addFormats(formats: { [name: string]: convict.Format }): void;
(config: convict.Schema): convict.Config;
}
var convict : convict;
export = convict;
}