2021-05-05 18:49:34 +02:00
|
|
|
function isTest() {
|
2022-12-12 23:02:32 +01:00
|
|
|
return isCypress() || isJest()
|
|
|
|
}
|
|
|
|
|
|
|
|
function isJest() {
|
|
|
|
return !!(process.env.NODE_ENV === "jest" || process.env.JEST_WORKER_ID)
|
|
|
|
}
|
|
|
|
|
|
|
|
function isCypress() {
|
|
|
|
return process.env.NODE_ENV === "cypress"
|
2021-05-05 18:49:34 +02:00
|
|
|
}
|
|
|
|
|
2022-05-04 13:28:21 +02:00
|
|
|
function isDev() {
|
|
|
|
return process.env.NODE_ENV !== "production"
|
|
|
|
}
|
|
|
|
|
2022-05-17 18:44:40 +02:00
|
|
|
let LOADED = false
|
|
|
|
if (!LOADED && isDev() && !isTest()) {
|
|
|
|
require("dotenv").config()
|
|
|
|
LOADED = true
|
|
|
|
}
|
|
|
|
|
2022-09-23 17:30:45 +02:00
|
|
|
const DefaultBucketName = {
|
|
|
|
BACKUPS: "backups",
|
|
|
|
APPS: "prod-budi-app-assets",
|
|
|
|
TEMPLATES: "templates",
|
|
|
|
GLOBAL: "global",
|
|
|
|
PLUGINS: "plugins",
|
|
|
|
}
|
|
|
|
|
2022-11-25 20:57:07 +01:00
|
|
|
const environment = {
|
2022-05-17 18:44:40 +02:00
|
|
|
isTest,
|
2022-12-12 23:02:32 +01:00
|
|
|
isJest,
|
2022-05-17 18:44:40 +02:00
|
|
|
isDev,
|
2022-12-15 12:35:22 +01:00
|
|
|
isProd: () => {
|
|
|
|
return !isDev()
|
|
|
|
},
|
2022-09-13 19:00:10 +02:00
|
|
|
JS_BCRYPT: process.env.JS_BCRYPT,
|
2021-04-14 15:13:48 +02:00
|
|
|
JWT_SECRET: process.env.JWT_SECRET,
|
2023-01-16 19:15:43 +01:00
|
|
|
ENCRYPTION_KEY: process.env.ENCRYPTION_KEY,
|
2022-04-27 23:36:45 +02:00
|
|
|
COUCH_DB_URL: process.env.COUCH_DB_URL || "http://localhost:4005",
|
2021-08-18 12:23:28 +02:00
|
|
|
COUCH_DB_USERNAME: process.env.COUCH_DB_USER,
|
2021-08-17 15:11:03 +02:00
|
|
|
COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD,
|
2022-02-10 10:28:46 +01:00
|
|
|
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
|
|
|
|
GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET,
|
2021-04-14 15:13:48 +02:00
|
|
|
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-06 20:27:24 +02:00
|
|
|
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
|
|
|
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
|
2021-09-21 12:49:32 +02:00
|
|
|
AWS_REGION: process.env.AWS_REGION,
|
2021-05-06 20:27:24 +02:00
|
|
|
MINIO_URL: process.env.MINIO_URL,
|
2022-12-15 12:35:22 +01:00
|
|
|
MINIO_ENABLED: process.env.MINIO_ENABLED || 1,
|
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,
|
2022-04-25 13:19:36 +02:00
|
|
|
ACCOUNT_PORTAL_URL:
|
|
|
|
process.env.ACCOUNT_PORTAL_URL || "https://account.budibase.app",
|
2022-09-12 11:43:26 +02:00
|
|
|
ACCOUNT_PORTAL_API_KEY: process.env.ACCOUNT_PORTAL_API_KEY || "",
|
2021-09-29 17:55:59 +02:00
|
|
|
DISABLE_ACCOUNT_PORTAL: process.env.DISABLE_ACCOUNT_PORTAL,
|
2022-05-03 23:58:19 +02:00
|
|
|
SELF_HOSTED: !!parseInt(process.env.SELF_HOSTED || ""),
|
2021-09-28 17:35:31 +02:00
|
|
|
COOKIE_DOMAIN: process.env.COOKIE_DOMAIN,
|
2022-07-08 11:52:23 +02:00
|
|
|
PLATFORM_URL: process.env.PLATFORM_URL || "",
|
2022-03-25 14:04:34 +01:00
|
|
|
POSTHOG_TOKEN: process.env.POSTHOG_TOKEN,
|
|
|
|
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
|
2022-03-22 01:23:22 +01:00
|
|
|
TENANT_FEATURE_FLAGS: process.env.TENANT_FEATURE_FLAGS,
|
2022-12-15 12:35:22 +01:00
|
|
|
CLOUDFRONT_CDN: process.env.CLOUDFRONT_CDN,
|
|
|
|
CLOUDFRONT_PRIVATE_KEY_64: process.env.CLOUDFRONT_PRIVATE_KEY_64,
|
|
|
|
CLOUDFRONT_PUBLIC_KEY_ID: process.env.CLOUDFRONT_PUBLIC_KEY_ID,
|
2022-09-23 17:30:45 +02:00
|
|
|
BACKUPS_BUCKET_NAME:
|
|
|
|
process.env.BACKUPS_BUCKET_NAME || DefaultBucketName.BACKUPS,
|
|
|
|
APPS_BUCKET_NAME: process.env.APPS_BUCKET_NAME || DefaultBucketName.APPS,
|
|
|
|
TEMPLATES_BUCKET_NAME:
|
|
|
|
process.env.TEMPLATES_BUCKET_NAME || DefaultBucketName.TEMPLATES,
|
|
|
|
GLOBAL_BUCKET_NAME:
|
|
|
|
process.env.GLOBAL_BUCKET_NAME || DefaultBucketName.GLOBAL,
|
|
|
|
PLUGIN_BUCKET_NAME:
|
|
|
|
process.env.PLUGIN_BUCKET_NAME || DefaultBucketName.PLUGINS,
|
2022-04-26 18:13:45 +02:00
|
|
|
USE_COUCH: process.env.USE_COUCH || true,
|
2022-05-24 10:12:39 +02:00
|
|
|
DEFAULT_LICENSE: process.env.DEFAULT_LICENSE,
|
2022-06-01 15:10:00 +02:00
|
|
|
SERVICE: process.env.SERVICE || "budibase",
|
2022-08-04 21:23:45 +02:00
|
|
|
LOG_LEVEL: process.env.LOG_LEVEL,
|
2022-08-05 18:13:03 +02:00
|
|
|
SESSION_UPDATE_PERIOD: process.env.SESSION_UPDATE_PERIOD,
|
2022-06-01 15:10:00 +02:00
|
|
|
DEPLOYMENT_ENVIRONMENT:
|
|
|
|
process.env.DEPLOYMENT_ENVIRONMENT || "docker-compose",
|
2022-05-03 23:58:19 +02:00
|
|
|
_set(key: any, value: any) {
|
2021-07-15 13:55:35 +02:00
|
|
|
process.env[key] = value
|
2022-11-28 18:54:04 +01:00
|
|
|
// @ts-ignore
|
|
|
|
environment[key] = value
|
2021-07-15 13:55:35 +02:00
|
|
|
},
|
2021-04-14 15:13:48 +02:00
|
|
|
}
|
2022-03-25 14:04:34 +01:00
|
|
|
|
|
|
|
// clean up any environment variable edge cases
|
2022-11-25 20:57:07 +01:00
|
|
|
for (let [key, value] of Object.entries(environment)) {
|
2022-03-25 14:04:34 +01:00
|
|
|
// handle the edge case of "0" to disable an environment variable
|
|
|
|
if (value === "0") {
|
2022-06-23 21:22:51 +02:00
|
|
|
// @ts-ignore
|
2022-11-28 20:12:23 +01:00
|
|
|
environment[key] = 0
|
2022-03-25 14:04:34 +01:00
|
|
|
}
|
2022-12-15 12:35:22 +01:00
|
|
|
// handle the edge case of "false" to disable an environment variable
|
|
|
|
if (value === "false") {
|
|
|
|
// @ts-ignore
|
|
|
|
environment[key] = 0
|
|
|
|
}
|
2022-03-25 14:04:34 +01:00
|
|
|
}
|
2022-05-23 23:14:44 +02:00
|
|
|
|
2023-01-11 10:37:37 +01:00
|
|
|
export default environment
|