diff --git a/server/.gitignore b/server/.gitignore index eb6aa5be8..ddd91029c 100644 --- a/server/.gitignore +++ b/server/.gitignore @@ -3,8 +3,6 @@ js # .vscode logs -src/secrets.ts - .nyc_output coverage .env @@ -15,3 +13,5 @@ scripts/arc-db-sync/songs.json scripts/validate-database-errs/* scripts/__JSON-TO-KTDB/**/*.json + +/src/lib/env/config.json \ No newline at end of file diff --git a/server/src/example-secrets.ts b/server/src/example-secrets.ts deleted file mode 100644 index 661215c03..000000000 --- a/server/src/example-secrets.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This is an example file for the secrets.ts file - which is not not available in the repository. - -export const CAPTCHA_SECRET_KEY = "change-me"; - -export const SESSION_SECRET = "change-me"; - -export const FLO_API_URL = "https://google.com"; - -export const EAG_API_URL = "https://google.com"; - -export const ARC_API_URL = "https://google.com"; diff --git a/server/src/lib/env/env.ts b/server/src/lib/env/env.ts new file mode 100644 index 000000000..d59b3d542 --- /dev/null +++ b/server/src/lib/env/env.ts @@ -0,0 +1,25 @@ +// barrel file for re-exporting env variables. + +const envVars = [ + "KTBKS_MONGO_BASE_URL", + "KTBKS_LOG_LEVEL", + "KTBKS_CAPTCHA_SECRET_KEY", + "KTBKS_SESSION_SECRET", + "KTBKS_FLO_API_URL", + "KTBKS_EAG_API_URL", + "KTBKS_ARC_API_URL", +]; + +for (const eVar of envVars) { + if (!process.env[eVar]) { + throw new Error(`${eVar} was not defined.`); + } +} + +export const MONGO_BASE_URL = process.env.KTBKS_MONGO_BASE_URL!; +export const LOG_LEVEL = process.env.KTBKS_LOG_LEVEL!; +export const SESSION_SECRET = process.env.KTBKS_SESSION_SECRET!; +export const CAPTCHA_SECRET_KEY = process.env.KTBKS_CAPTCHA_SECRET_KEY!; +export const FLO_API_URL = process.env.KTBKS_FLO_API_URL!; +export const EAG_API_URL = process.env.KTBKS_EAG_API_URL!; +export const ARC_API_URL = process.env.KTBKS_ARC_API_URL!;