2021-03-29 16:00:40 +02:00
|
|
|
function isDev() {
|
|
|
|
return process.env.NODE_ENV !== "production"
|
|
|
|
}
|
|
|
|
|
2021-04-15 17:25:48 +02:00
|
|
|
function isTest() {
|
|
|
|
return (
|
|
|
|
process.env.NODE_ENV === "jest" ||
|
|
|
|
process.env.NODE_ENV === "cypress" ||
|
|
|
|
process.env.JEST_WORKER_ID != null
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-03-29 16:00:40 +02:00
|
|
|
let LOADED = false
|
2021-05-05 18:49:34 +02:00
|
|
|
if (!LOADED && isDev() && !isTest()) {
|
2021-03-29 16:00:40 +02:00
|
|
|
require("dotenv").config()
|
|
|
|
LOADED = true
|
|
|
|
}
|
|
|
|
|
2020-12-16 20:50:02 +01:00
|
|
|
module.exports = {
|
2021-08-05 10:59:08 +02:00
|
|
|
NODE_ENV: process.env.NODE_ENV,
|
2021-09-20 12:26:19 +02:00
|
|
|
SELF_HOSTED: !!parseInt(process.env.SELF_HOSTED),
|
2020-12-16 20:50:02 +01:00
|
|
|
PORT: process.env.PORT,
|
2021-05-21 15:38:46 +02:00
|
|
|
CLUSTER_PORT: process.env.CLUSTER_PORT,
|
2020-12-16 20:50:02 +01:00
|
|
|
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
|
|
|
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
|
2021-03-29 16:00:40 +02:00
|
|
|
MINIO_URL: process.env.MINIO_URL,
|
|
|
|
COUCH_DB_URL: process.env.COUCH_DB_URL,
|
|
|
|
LOG_LEVEL: process.env.LOG_LEVEL,
|
2021-03-29 18:31:41 +02:00
|
|
|
JWT_SECRET: process.env.JWT_SECRET,
|
|
|
|
SALT_ROUNDS: process.env.SALT_ROUNDS,
|
2021-04-27 18:29:05 +02:00
|
|
|
REDIS_URL: process.env.REDIS_URL,
|
|
|
|
REDIS_PASSWORD: process.env.REDIS_PASSWORD,
|
2021-05-11 16:23:03 +02:00
|
|
|
INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
|
2021-08-05 10:59:08 +02:00
|
|
|
MULTI_TENANCY: process.env.MULTI_TENANCY,
|
2021-09-29 17:55:59 +02:00
|
|
|
DISABLE_ACCOUNT_PORTAL: process.env.DISABLE_ACCOUNT_PORTAL,
|
2021-09-14 15:18:13 +02:00
|
|
|
ACCOUNT_PORTAL_URL: process.env.ACCOUNT_PORTAL_URL,
|
2021-09-27 23:31:13 +02:00
|
|
|
SMTP_FALLBACK_ENABLED: process.env.SMTP_FALLBACK_ENABLED,
|
2021-09-27 15:57:22 +02:00
|
|
|
SMTP_USER: process.env.SMTP_USER,
|
|
|
|
SMTP_PASSWORD: process.env.SMTP_PASSWORD,
|
|
|
|
SMTP_HOST: process.env.SMTP_HOST,
|
|
|
|
SMTP_PORT: process.env.SMTP_PORT,
|
|
|
|
SMTP_FROM_ADDRESS: process.env.SMTP_FROM_ADDRESS,
|
2021-10-04 12:30:59 +02:00
|
|
|
PLATFORM_URL: process.env.PLATFORM_URL,
|
2021-10-06 17:50:15 +02:00
|
|
|
COOKIE_DOMAIN: process.env.COOKIE_DOMAIN,
|
2021-11-04 15:53:03 +01:00
|
|
|
APPS_URL: process.env.APPS_URL,
|
2020-12-16 20:50:02 +01:00
|
|
|
_set(key, value) {
|
|
|
|
process.env[key] = value
|
|
|
|
module.exports[key] = value
|
|
|
|
},
|
2021-03-29 16:00:40 +02:00
|
|
|
isDev,
|
2021-04-15 17:25:48 +02:00
|
|
|
isTest,
|
|
|
|
isProd: () => {
|
|
|
|
return !isDev()
|
|
|
|
},
|
2020-12-16 20:50:02 +01:00
|
|
|
}
|
2021-10-11 18:59:44 +02:00
|
|
|
|
2021-11-04 15:53:03 +01:00
|
|
|
// if some var haven't been set, define them
|
|
|
|
if (!module.exports.APPS_URL) {
|
|
|
|
module.exports.APPS_URL = isDev()
|
|
|
|
? "http://localhost:4001"
|
|
|
|
: "http://app-service:4002"
|
|
|
|
}
|
|
|
|
|
2021-10-11 18:59:44 +02:00
|
|
|
// clean up any environment variable edge cases
|
|
|
|
for (let [key, value] of Object.entries(module.exports)) {
|
|
|
|
// handle the edge case of "0" to disable an environment variable
|
|
|
|
if (value === "0") {
|
|
|
|
module.exports[key] = 0
|
|
|
|
}
|
|
|
|
}
|