summaryrefslogtreecommitdiff
path: root/src/lib/env.ts
diff options
context:
space:
mode:
authorJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-12 15:49:03 +0100
committerJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-12 15:49:03 +0100
commit37020d847e66e57913d493716e98f4dcab749262 (patch)
treea6bfa0c49bcec61ff91465f323142db43511a122 /src/lib/env.ts
parent18b85566df437ac932f59e94cbec771a4a331927 (diff)
Applies Prettier
Diffstat (limited to 'src/lib/env.ts')
-rw-r--r--src/lib/env.ts32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/lib/env.ts b/src/lib/env.ts
index 20f18f5..e267f81 100644
--- a/src/lib/env.ts
+++ b/src/lib/env.ts
@@ -4,9 +4,9 @@ import dotenv from 'dotenv';
dotenv.config({ path: '../../.env' });
type Env = {
- PAYPAL_LIVE_CLIENT_ID: string,
- PAYPAL_SANDBOX_CLIENT_ID: string,
- ENVIRONMENT: 'dev' | 'prod',
+ PAYPAL_LIVE_CLIENT_ID: string;
+ PAYPAL_SANDBOX_CLIENT_ID: string;
+ ENVIRONMENT: 'dev' | 'prod';
};
type DirtyEnv = { [key in keyof Env]?: string };
@@ -19,25 +19,23 @@ const ENV: { [key in keyof Env]: number } = {
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.`);
- }
+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(`
+ 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];
- });
+ }
+ return [key, value];
+});
const sanitisedEnv = Object.fromEntries(sanitisedEnvEntries) as Env;
-export default sanitisedEnv; \ No newline at end of file
+export default sanitisedEnv;