summaryrefslogtreecommitdiff
path: root/api-src/_env.ts
diff options
context:
space:
mode:
authorJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-12 09:39:41 +0100
committerJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-12 09:41:58 +0100
commit6549313a54e7fede18cfa170df82c29f511d76d7 (patch)
tree2dc148824adfa08dd7b32cf2ca2179e6e3e23dfc /api-src/_env.ts
parentfae665188dfd2c333c6fbba43a8d3c776b285d27 (diff)
No more API build step
Diffstat (limited to 'api-src/_env.ts')
-rw-r--r--api-src/_env.ts48
1 files changed, 0 insertions, 48 deletions
diff --git a/api-src/_env.ts b/api-src/_env.ts
deleted file mode 100644
index 536f8d7..0000000
--- a/api-src/_env.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import path from 'path';
-import dotenv from 'dotenv';
-
-// Parsing the env file.
-dotenv.config({ path: path.resolve(__dirname, '../.env') });
-
-type Env = {
- PAYPAL_LIVE_CLIENT_ID: string,
- PAYPAL_LIVE_SECRET: string,
- PAYPAL_SANDBOX_CLIENT_ID: string,
- PAYPAL_SANDBOX_SECRET: string,
- ENVIRONMENT: 'dev' | 'prod',
-};
-
-type DirtyEnv = { [key in keyof Env]?: string };
-
-const ENV: { [key in keyof Env]: number } = {
- PAYPAL_LIVE_CLIENT_ID: 1,
- PAYPAL_LIVE_SECRET: 1,
- PAYPAL_SANDBOX_CLIENT_ID: 1,
- PAYPAL_SANDBOX_SECRET: 1,
- ENVIRONMENT: 1,
-};
-
-const { env }: { env: DirtyEnv } = process;
-
-const sanitisedEnvEntries =
- (Object.keys(ENV) as (keyof Env)[])
- .map<[keyof Env, string]>(key => {
- const value = env[key];
- if (!value) {
- throw new Error(`Environment not configured correctly. ${key} was not defined.`);
- }
-
- if (key === 'ENVIRONMENT') {
- if (!['dev', 'prod'].includes(value)) {
- throw new Error(`
- Environment not configured correctly. ${key} must be
- either 'dev' or 'prod', but '${value}' was provided.
- `);
- }
- }
- return [key, value];
- });
-
-const sanitisedEnv = Object.fromEntries(sanitisedEnvEntries) as Env;
-
-export default sanitisedEnv; \ No newline at end of file