-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenv.config.js
More file actions
35 lines (28 loc) · 812 Bytes
/
Copy pathenv.config.js
File metadata and controls
35 lines (28 loc) · 812 Bytes
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
const APP_ENV = process.env.APP_ENV || 'development'
const local = {
API_URL: 'http://127.0.0.1:8000/internal',
}
const development = {
API_URL: 'https://api-dev.core.ac.uk/internal',
}
const staging = {
API_URL: 'https://api-stg.core.ac.uk/internal',
}
const production = {
API_URL: 'https://api.core.ac.uk/internal',
}
const validate = (config) =>
['API_URL', 'API_KEY'].forEach((param) => {
if (config[param] == null) throw new Error(`${param} is not configured.`)
})
const env = { local, development, staging, production }
const config = {
...env.production,
...env[APP_ENV],
API_KEY: process.env.API_KEY,
SENTRY_DSN: process.env.SENTRY_DSN,
GA_TRACKING_CODE: process.env.GA_TRACKING_CODE,
BUILD_TARGET: process.env.BUILD_TARGET,
}
validate(config)
module.exports = config