2021-03-25 07:21:23 +13:00
|
|
|
function isTest() {
|
|
|
|
return (
|
|
|
|
process.env.NODE_ENV === "jest" ||
|
|
|
|
process.env.NODE_ENV === "cypress" ||
|
|
|
|
process.env.JEST_WORKER_ID != null
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-03-24 04:37:11 +13:00
|
|
|
function isDev() {
|
|
|
|
return (
|
|
|
|
process.env.NODE_ENV !== "production" &&
|
2021-03-25 07:21:23 +13:00
|
|
|
process.env.BUDIBASE_ENVIRONMENT !== "production"
|
2021-03-24 04:37:11 +13:00
|
|
|
)
|
|
|
|
}
|
2020-10-27 06:49:33 +13:00
|
|
|
|
|
|
|
let LOADED = false
|
2021-03-25 07:21:23 +13:00
|
|
|
if (!LOADED && isDev() && !isTest()) {
|
2021-03-24 04:37:11 +13:00
|
|
|
require("dotenv").config()
|
2020-10-27 06:49:33 +13:00
|
|
|
LOADED = true
|
|
|
|
}
|
|
|
|
|
2020-05-15 02:12:30 +12:00
|
|
|
module.exports = {
|
2021-03-24 04:37:11 +13:00
|
|
|
// important
|
2020-05-15 02:12:30 +12:00
|
|
|
PORT: process.env.PORT,
|
2021-03-24 04:37:11 +13:00
|
|
|
JWT_SECRET: process.env.JWT_SECRET,
|
2020-05-15 02:12:30 +12:00
|
|
|
COUCH_DB_URL: process.env.COUCH_DB_URL,
|
2021-03-24 04:37:11 +13:00
|
|
|
MINIO_URL: process.env.MINIO_URL,
|
|
|
|
WORKER_URL: process.env.WORKER_URL,
|
|
|
|
SELF_HOSTED: process.env.SELF_HOSTED,
|
|
|
|
AWS_REGION: process.env.AWS_REGION,
|
|
|
|
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
|
2021-03-25 01:54:59 +13:00
|
|
|
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
|
|
|
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
|
2021-03-25 07:21:23 +13:00
|
|
|
USE_QUOTAS: process.env.USE_QUOTAS,
|
2021-04-28 04:29:05 +12:00
|
|
|
REDIS_URL: process.env.REDIS_URL,
|
|
|
|
REDIS_PASSWORD: process.env.REDIS_PASSWORD,
|
2021-05-12 02:23:03 +12:00
|
|
|
INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
|
2021-08-05 20:59:08 +12:00
|
|
|
MULTI_TENANCY: process.env.MULTI_TENANCY,
|
2021-03-24 04:37:11 +13:00
|
|
|
// environment
|
|
|
|
NODE_ENV: process.env.NODE_ENV,
|
|
|
|
JEST_WORKER_ID: process.env.JEST_WORKER_ID,
|
|
|
|
BUDIBASE_ENVIRONMENT: process.env.BUDIBASE_ENVIRONMENT,
|
|
|
|
// minor
|
2020-05-15 02:12:30 +12:00
|
|
|
SALT_ROUNDS: process.env.SALT_ROUNDS,
|
|
|
|
LOGGER: process.env.LOGGER,
|
2020-10-29 09:35:06 +13:00
|
|
|
LOG_LEVEL: process.env.LOG_LEVEL,
|
2020-09-19 03:50:52 +12:00
|
|
|
AUTOMATION_DIRECTORY: process.env.AUTOMATION_DIRECTORY,
|
|
|
|
AUTOMATION_BUCKET: process.env.AUTOMATION_BUCKET,
|
2020-09-19 00:51:56 +12:00
|
|
|
SENDGRID_API_KEY: process.env.SENDGRID_API_KEY,
|
2020-10-07 07:13:41 +13:00
|
|
|
DYNAMO_ENDPOINT: process.env.DYNAMO_ENDPOINT,
|
2021-03-24 04:37:11 +13:00
|
|
|
// old - to remove
|
|
|
|
CLIENT_ID: process.env.CLIENT_ID,
|
|
|
|
BUDIBASE_DIR: process.env.BUDIBASE_DIR,
|
2020-10-29 09:35:06 +13:00
|
|
|
DEPLOYMENT_DB_URL: process.env.DEPLOYMENT_DB_URL,
|
2021-03-23 05:39:11 +13:00
|
|
|
BUDIBASE_API_KEY: process.env.BUDIBASE_API_KEY,
|
|
|
|
USERID_API_KEY: process.env.USERID_API_KEY,
|
|
|
|
DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL,
|
2021-09-14 22:18:02 +12:00
|
|
|
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
|
2020-10-29 09:35:06 +13:00
|
|
|
_set(key, value) {
|
|
|
|
process.env[key] = value
|
2020-10-29 11:24:44 +13:00
|
|
|
module.exports[key] = value
|
2020-10-29 09:35:06 +13:00
|
|
|
},
|
2021-03-25 07:21:23 +13:00
|
|
|
isTest,
|
2021-03-24 04:37:11 +13:00
|
|
|
isDev,
|
2021-03-25 07:21:23 +13:00
|
|
|
isProd: () => {
|
|
|
|
return !isDev()
|
|
|
|
},
|
2020-05-15 02:12:30 +12:00
|
|
|
}
|
2021-09-21 05:24:09 +12:00
|
|
|
|
|
|
|
// convert any strings to numbers if required, like "0" would be true otherwise
|
|
|
|
for (let [key, value] of Object.entries(module.exports)) {
|
|
|
|
if (typeof value === "string" && !isNaN(parseInt(value))) {
|
|
|
|
module.exports[key] = parseInt(value)
|
|
|
|
}
|
|
|
|
}
|