-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinitialConfig.js
More file actions
99 lines (96 loc) · 2.43 KB
/
initialConfig.js
File metadata and controls
99 lines (96 loc) · 2.43 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
const config = () => ({
redisHost: undefined,
ClientId: undefined,
ClientSecret: undefined,
spikeURL: undefined,
tokenGrantType: 'client_credentials',
tokenAudience: undefined,
tokenRedisKeyName: undefined,
// path relative to current folder ( config )
spikePublicKeyFullPath: undefined,
useRedis: false,
httpsValidation: false,
hostHeader: false,
retries: 3,
sleepBetweenRetries: 500
})
// Configuration validation mapper, each field with required
// value true will be strictly validated and if forgotten or bad value was entered, throwing
// an error with indication for the problem.
// The mapping configuration goes like this:
/**
* {
* field_name: {
* type (String):
* Type of the field in manner of `typeof` results.
*
* required (Boolean):
* Indicates if the field is required.
*
* dependsOn ({ fieldName: String, fieldValue: any} | undefined):
* Object containing field name which the current field is depends on and field
* value to check against.
* If the dependsOn field is included, the field becomes required.
*
* errorMessage (String | undefined):
* Error message to display when the field invalidates.
* If no error message was specified, using default missing field error message.
* }
* }
*/
const configValidationMap = {
redisHost: {
type: 'string',
required: false,
dependsOn: { fieldName: 'useRedis', fieldValue: true }
},
tokenRedisKeyName: {
type: 'string',
required: false,
dependsOn: { fieldName: 'useRedis', fieldValue: true }
},
clientId: {
type: 'string',
required: true
},
clientSecret: {
type: 'string',
required: true
},
spikeURL: {
type: 'string',
required: true
},
tokenAudience: {
type: 'string',
required: true
},
spikePublicKeyFullPath: {
type: 'string',
required: true,
},
useRedis: {
type: 'boolean',
required: false
},
httpsValidation: {
type: 'boolean',
required: false
},
hostHeader: {
type: 'boolean',
required: false
},
retries: {
type: 'number',
required: true
},
sleepBetweenRetries: {
type: 'number',
required: true
}
};
module.exports = {
config,
configValidationMap
};