forked from eduardoboucas/staticman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
102 lines (93 loc) · 2.56 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
'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'
},
githubToken: {
doc: 'Access token to the GitHub account being used to push files with.',
format: String,
default: null,
env: 'GITHUB_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