-
Notifications
You must be signed in to change notification settings - Fork 30
/
env.js
46 lines (36 loc) · 978 Bytes
/
env.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
'use strict'
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'development'
}
if (!process.env.CDN_URL) {
process.env.CDN_URL = 'https://cdn.microlink.io'
}
if (process.env.NODE_ENV === 'development') {
;['STRIPE_KEY', 'PAYMENT_API_KEY', 'PAYMENT_ENDPOINT'].forEach(
key => (process.env[key] = process.env[key] || 'stub')
)
}
const required = [
'CDN_URL',
'STRIPE_KEY',
'PAYMENT_API_KEY',
'PAYMENT_ENDPOINT'
]
const missing = required.filter(key => process.env[key] == null)
if (missing.length > 0) {
throw new Error(
`Missing required environment variable(s): ${missing.join(', ')}`
)
}
const DEV_URL = 'http://localhost:8000'
const ALIAS_URL = 'https://microlink.io'
const isDev = process.env.NODE_ENV === 'development'
const SITE_URL = isDev
? DEV_URL
: process.env.DEPLOY_URL || process.env.NOW_URL || ALIAS_URL
const CANONICAL_URL = isDev ? DEV_URL : ALIAS_URL
module.exports = {
...process.env,
SITE_URL,
CANONICAL_URL
}