diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/env.ts | 32 | ||||
| -rw-r--r-- | src/lib/localeStaticPaths.ts | 4 |
2 files changed, 17 insertions, 19 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; diff --git a/src/lib/localeStaticPaths.ts b/src/lib/localeStaticPaths.ts index 55c3d9a..b75065d 100644 --- a/src/lib/localeStaticPaths.ts +++ b/src/lib/localeStaticPaths.ts @@ -2,9 +2,9 @@ import type Locale from '../types/Locale'; // Defines what values to insert into the [locale] URL path parameter // when generating a static site -const localeStaticPaths: { params: { locale: Locale} }[] = [ +const localeStaticPaths: { params: { locale: Locale } }[] = [ { params: { locale: 'sco' } }, { params: { locale: 'en-GB' } }, -] +]; export default localeStaticPaths; |
