-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
70 lines (63 loc) · 1.47 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
62
63
64
65
66
67
68
69
70
'use strict'
const convict = require('convict')
const schema = {
env: {
doc: 'The applicaton environment',
format: ['production', 'development', 'test'],
default: 'development',
env: 'NODE_ENV'
},
port: {
doc: 'The port to bind the application to',
format: 'port',
default: 0,
env: 'PORT'
},
githubApiToken: {
doc: 'Access token to the GitHub API',
format: String,
default: null,
env: 'GITHUB_API_TOKEN'
},
herokuApiToken: {
doc: 'Access token to the Heroku Platform API',
format: String,
default: null,
env: 'HEROKU_API_TOKEN'
},
webhookEndpoint: {
doc: 'Endpoint used to handle webhook requests',
format: String,
default: '/',
env: 'WEBHOOK_ENDPOINT'
},
webhookSecret: {
doc: 'Secret to decode webhook requests with',
format: String,
default: '',
env: 'GITHUB_WEBHOOK_SECRET'
},
pullRequest: {
branch: {
doc: 'Name of the branch to watch for PRs',
format: String,
default: 'master',
env: 'PR_BRANCH'
}
},
buildpack: {
doc: 'URL of the Heroku buildpack to use',
format: String,
default: null,
env: 'BUILDPACK_URL'
}
}
let config = convict(schema)
try {
let configFilePath = `${__dirname}/config.${config.get('env')}.json`
config.loadFile(configFilePath)
config.validate()
console.log(`Loaded config from local file (${configFilePath})`)
} catch (err) {}
module.exports = config
module.exports.schema = schema