budibase/packages/backend-core/src/environment.ts

77 lines
2.6 KiB
TypeScript
Raw Normal View History

function isTest() {
return (
process.env.NODE_ENV === "jest" ||
process.env.NODE_ENV === "cypress" ||
process.env.JEST_WORKER_ID != null
)
}
2022-05-04 13:28:21 +02:00
function isDev() {
return process.env.NODE_ENV !== "production"
}
let LOADED = false
if (!LOADED && isDev() && !isTest()) {
require("dotenv").config()
LOADED = true
}
const env = {
isTest,
isDev,
JWT_SECRET: process.env.JWT_SECRET,
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,
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET,
SALT_ROUNDS: process.env.SALT_ROUNDS,
REDIS_URL: process.env.REDIS_URL,
REDIS_PASSWORD: process.env.REDIS_PASSWORD,
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,
MINIO_URL: process.env.MINIO_URL,
INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
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",
ACCOUNT_PORTAL_API_KEY: process.env.ACCOUNT_PORTAL_API_KEY,
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 || "",
POSTHOG_TOKEN: process.env.POSTHOG_TOKEN,
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
TENANT_FEATURE_FLAGS: process.env.TENANT_FEATURE_FLAGS,
BACKUPS_BUCKET_NAME: process.env.BACKUPS_BUCKET_NAME || "backups",
APPS_BUCKET_NAME: process.env.APPS_BUCKET_NAME || "prod-budi-app-assets",
TEMPLATES_BUCKET_NAME: process.env.TEMPLATES_BUCKET_NAME || "templates",
GLOBAL_BUCKET_NAME: process.env.GLOBAL_BUCKET_NAME || "global",
GLOBAL_CLOUD_BUCKET_NAME:
process.env.GLOBAL_CLOUD_BUCKET_NAME || "prod-budi-tenant-uploads",
USE_COUCH: process.env.USE_COUCH || true,
DISABLE_DEVELOPER_LICENSE: process.env.DISABLE_DEVELOPER_LICENSE,
2022-05-24 10:12:39 +02:00
DEFAULT_LICENSE: process.env.DEFAULT_LICENSE,
SERVICE: process.env.SERVICE || "budibase",
2022-07-14 20:02:00 +02:00
MEMORY_LEAK_CHECK: process.env.MEMORY_LEAK_CHECK || false,
LOG_LEVEL: process.env.LOG_LEVEL,
DEPLOYMENT_ENVIRONMENT:
process.env.DEPLOYMENT_ENVIRONMENT || "docker-compose",
2022-05-03 23:58:19 +02:00
_set(key: any, value: any) {
process.env[key] = value
module.exports[key] = value
},
}
// clean up any environment variable edge cases
2022-05-23 23:14:44 +02:00
for (let [key, value] of Object.entries(env)) {
// handle the edge case of "0" to disable an environment variable
if (value === "0") {
// @ts-ignore
2022-05-23 23:14:44 +02:00
env[key] = 0
}
}
2022-05-23 23:14:44 +02:00
export = env