-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
144 lines (135 loc) · 3.63 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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
'use strict'
const convict = require('convict')
const path = require('path')
const schema = {
akismet: {
site: {
doc: 'URL of an Akismet account used for spam checking.',
docExample: 'http://yourdomain.com',
format: String,
default: null,
env: 'AKISMET_SITE'
},
apiKey: {
doc: 'API key to be used with Akismet.',
format: String,
default: null,
env: 'AKISMET_API_KEY'
}
},
analytics: {
uaTrackingId: {
doc: 'Universal Analytics account ID.',
docExample: 'uaTrackingId: "UA-XXXX-XX"',
format: String,
default: null,
env: 'UA_TRACKING_ID'
}
},
email: {
apiKey: {
doc: 'Mailgun API key to be used for email notifications. Will be overridden by a `notifications.apiKey` parameter in the site config, if one is set.',
format: String,
default: null,
env: 'EMAIL_API_KEY'
},
domain: {
doc: 'Domain to be used with Mailgun for email notifications. Will be overridden by a `notifications.domain` parameter in the site config, if one is set.',
format: String,
default: 'staticman.net',
env: 'EMAIL_DOMAIN'
},
fromAddress: {
doc: 'Email address to send notifications from. Will be overridden by a `notifications.fromAddress` parameter in the site config, if one is set.',
format: String,
default: '[email protected]',
env: 'EMAIL_FROM'
}
},
env: {
doc: 'The applicaton environment.',
format: ['production', 'development', 'test'],
default: 'development',
env: 'NODE_ENV'
},
githubAccessTokenUri: {
doc: 'URI for the GitHub authentication provider.',
format: String,
default: 'https://github.com/login/oauth/access_token',
env: 'GITHUB_ACCESS_TOKEN_URI'
},
githubAppID: {
doc: 'ID of the GitHub App.',
format: String,
default: null,
env: 'GITHUB_APP_ID'
},
githubBaseUrl: {
doc: 'Base URL for the GitHub API.',
format: String,
default: 'https://api.github.com',
env: 'GITHUB_BASE_URL'
},
githubPrivateKey: {
doc: 'Private key for the GitHub App.',
format: String,
default: null,
env: 'GITHUB_PRIVATE_KEY'
},
githubToken: {
doc: 'Access token to the GitHub account (legacy)',
format: String,
default: null,
env: 'GITHUB_TOKEN'
},
gitlabAccessTokenUri: {
doc: 'URI for the GitLab authentication provider.',
format: String,
default: 'https://gitlab.com/oauth/token',
env: 'GITLAB_ACCESS_TOKEN_URI'
},
gitlabBaseUrl: {
doc: 'Base URL for the GitLab API.',
format: String,
default: 'https://gitlab.com',
env: 'GITLAB_BASE_URL'
},
gitlabToken: {
doc: 'Access token to the GitLab account being used to push files with.',
format: String,
default: null,
env: 'GITLAB_TOKEN'
},
port: {
doc: 'The port to bind the application to.',
format: 'port',
default: 0,
env: 'PORT'
},
rsaPrivateKey: {
doc: 'RSA private key to encrypt sensitive configuration parameters with.',
docExample: 'rsaPrivateKey: "-----BEGIN RSA PRIVATE KEY-----\\nkey\\n-----END RSA PRIVATE KEY-----"',
format: String,
default: null,
env: 'RSA_PRIVATE_KEY'
},
logging: {
slackWebhook: {
doc: 'Slack webhook URL to pipe log output to',
format: String,
default: null,
env: 'SLACK_WEBHOOK'
}
}
}
let config
try {
config = convict(schema)
const fileName = 'config.' + config.get('env') + '.json'
config.loadFile(path.join(__dirname, fileName))
config.validate()
console.log('(*) Local config file loaded')
} catch (e) {
}
module.exports = config
module.exports.schema = schema