-
Notifications
You must be signed in to change notification settings - Fork 12
/
config.js
61 lines (55 loc) · 1.6 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var convict = require('convict');
var cronParser = require('cron-parser');
var appManifest = require('./app');
var appEnv = appManifest.env;
// Could probably be more clever here by transforming the Heroku-specific
// configuration to node-convict-compatible, but seems okay for now
var isURL = require('validator').isURL;
var conf = convict({
databaseURL: {
doc: 'The URL for the Postgres database, including username and password.',
env: 'DATABASE_URL',
format(val) {
isURL(val, {require_protocol: true, protocols: ['postgres']}, 'should be a Postgres URL');
},
default: ''
},
slackToken: {
doc: appEnv.SLACK_TOKEN.description,
env: 'SLACK_TOKEN',
format: String,
default: null
},
reportingInterval: {
doc: appEnv.REPORTING_INTERVAL.description,
env: 'REPORTING_INTERVAL',
format(val) {
try {
cronParser.parseExpression(val);
} catch (err) {
throw new Error('REPORTING_INTERVAL should be in crontab format, see https://github.com/harrisiirak/cron-parser');
}
},
default: appEnv.REPORTING_INTERVAL.value
},
reportingThreshold: {
doc: appEnv.REPORTING_THRESHOLD.description,
env: 'REPORTING_THRESHOLD',
format: 'nat',
default: 10
},
statsChannel: {
doc: appEnv.STATS_CHANNEL.description,
env: 'STATS_CHANNEL',
format: String,
default: appEnv.STATS_CHANNEL.value
},
topUnknownsToQuery: {
doc: appEnv.TOP_UNKNOWNS_TO_QUERY.description,
env: 'TOP_UNKNOWNS_TO_QUERY',
format: 'nat',
default: appEnv.TOP_UNKNOWNS_TO_QUERY.value
}
});
conf.validate();
module.exports = conf;