-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a333c4c
commit 91553e0
Showing
1 changed file
with
12 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,35 @@ | ||
import { createUrl } from 'src/shared/createUrl'; | ||
import { invariant } from 'src/shared/invariant'; | ||
|
||
const backendUrl = (url: string | undefined, backend_env: string | undefined) => { | ||
function backendUrl(url: string, backend_env?: string | undefined): string; | ||
function backendUrl(url: string | undefined, backend_env?: string | undefined): string | undefined; | ||
function backendUrl(url: string | undefined, backend_env: string | undefined) { | ||
if (url) { | ||
return createUrl({ | ||
base: url, | ||
pathname: '', | ||
searchParams: backend_env ? { backend_env } : undefined, | ||
}).toString(); | ||
} | ||
}; | ||
} | ||
|
||
export const BACKEND_ENV = process.env.BACKEND_ENV; | ||
invariant(process.env.DEFI_SDK_API_TOKEN, 'DEFI_SDK_API_TOKEN is required in env'); | ||
export const DEFI_SDK_API_TOKEN = process.env.DEFI_SDK_API_TOKEN; | ||
invariant(process.env.DEFI_SDK_API_URL, 'DEFI_SDK_API_URL is required in env'); | ||
export const DEFI_SDK_API_URL = backendUrl(process.env.DEFI_SDK_API_URL, BACKEND_ENV); | ||
invariant(process.env.DEFI_SDK_TESTNET_API_URL, 'DEFI_SDK_TESTNET_API_URL is required in env'); | ||
export const DEFI_SDK_TESTNET_API_URL = backendUrl(process.env.DEFI_SDK_TESTNET_API_URL, BACKEND_ENV); | ||
invariant(process.env.ZERION_API_URL, 'ZERION_API_URL is required in env'); | ||
export const ZERION_API_URL = backendUrl(process.env.ZERION_API_URL, BACKEND_ENV); | ||
invariant(process.env.ZERION_TESTNET_API_URL, 'ZERION_TESTNET_API_URL is required in env'); | ||
export const ZERION_TESTNET_API_URL = backendUrl(process.env.ZERION_TESTNET_API_URL, BACKEND_ENV); | ||
invariant(process.env.DEFI_SDK_TRANSACTIONS_API_URL, 'DEFI_SDK_TRANSACTIONS_API_URL is required in env'); | ||
export const DEFI_SDK_TRANSACTIONS_API_URL = backendUrl(process.env.DEFI_SDK_TRANSACTIONS_API_URL, BACKEND_ENV); | ||
|
||
invariant(process.env.PROXY_URL, 'PROXY_URL is required in env'); | ||
export const PROXY_URL = process.env.PROXY_URL; | ||
export const SOCIAL_API_URL = process.env.SOCIAL_API_URL; | ||
export const MIXPANEL_TOKEN_PUBLIC = process.env.MIXPANEL_TOKEN_PUBLIC; | ||
export const FEATURE_LOYALTY_FLOW = process.env.FEATURE_LOYALTY_FLOW === 'on' ? 'on' : null; // avoid accidental false-positives for truthy "off" | ||
export const SLOW_MODE = false; | ||
|
||
if (!PROXY_URL) { | ||
throw new Error('PROXY_URL must be defined in ENV'); | ||
} | ||
if (!ZERION_API_URL) { | ||
throw new Error('ZERION_API_URL must be defined in ENV'); | ||
} |