-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
38 lines (35 loc) · 1.22 KB
/
config.js
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
const { ConfigValidationError } = require('./config-validation-error')
class Config {
constructor (environmentVariables) {
this.fluxClientId = environmentVariables.FLUX_CLIENT_ID
this.fluxClientSecret = environmentVariables.FLUX_CLIENT_SECRET
this.fluxAccessTokenRetryPeriod =
parseInt(environmentVariables.FLUX_PUBLIC_KEY_POLL_INTERVAL, 10) ||
86400000
this.fluxApiUrlBase =
environmentVariables.FLUX_API_URL_BASE || 'https://api.test.tryflux.com'
this.fluxApiWebhooksBase =
environmentVariables.FLUX_API_WEBHOOKS_URL_BASE ||
'https://webhooks.test.tryflux.com'
this.httpsRequestTimeout =
environmentVariables.HTTPS_REQUEST_TIMEOUT || 120000
this.webserverPort = environmentVariables.PORT || 80
this.apiRequestTimeout =
parseInt(environmentVariables.PUBLIC_API_REQUEST_TIME_OUT, 10) || 120000
}
isConfigValid () {
const errors = []
if (!this.fluxClientId && !this.fluxClientSecret) {
errors.push('FLUX_CLIENT_ID or FLUX_CLIENT_SECRET')
}
if (errors.length > 0) {
throw new ConfigValidationError(
`Missing the following environment variables: ${errors.join(', ')}`
)
}
return true
}
}
module.exports = {
Config
}