From 586b63fbac2db1b24d5bcff0b782bc97ff481889 Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Tue, 12 Dec 2023 00:11:17 +0000 Subject: [PATCH] feat: Update environment variable retrieval in codebase --- apps/web/app/constants.ts | 6 ++++-- apps/web/app/services/client/api/employee.ts | 2 +- apps/web/pages/_app.tsx | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/apps/web/app/constants.ts b/apps/web/app/constants.ts index edb86fd19..7ba67c7e4 100644 --- a/apps/web/app/constants.ts +++ b/apps/web/app/constants.ts @@ -33,7 +33,9 @@ export const RECAPTCHA_SITE_KEY = getNextPublicEnv('NEXT_PUBLIC_CAPTCHA_SITE_KEY export const RECAPTCHA_SECRET_KEY = process.env.CAPTCHA_SECRET_KEY; export const GAUZY_API_SERVER_URL = process.env.GAUZY_API_SERVER_URL || 'https://api.gauzy.co/api'; +export const GAUZY_API_BASE_SERVER_URL = getNextPublicEnv('NEXT_PUBLIC_GAUZY_API_SERVER_URL', 'https://api.gauzy.co'); +// Invite export const INVITE_CALLBACK_URL = process.env.INVITE_CALLBACK_URL || 'https://app.ever.team/auth/passcode'; export const INVITE_CALLBACK_PATH = '/auth/passcode'; export const VERIFY_EMAIL_CALLBACK_URL = process.env.VERIFY_EMAIL_CALLBACK_URL || 'https://app.ever.team/verify-email'; @@ -88,8 +90,8 @@ export const BOARD_FIREBASE_CONFIG = getNextPublicEnv('NEXT_PUBLIC_BOARD_FIREBAS // Jitsu export const jitsuConfiguration: () => JitsuOptions = () => ({ - host: process.env.NEXT_PUBLIC_JITSU_BROWSER_URL || '', - writeKey: process.env.NEXT_PUBLIC_JITSU_BROWSER_WRITE_KEY || '', + host: getNextPublicEnv('NEXT_PUBLIC_JITSU_BROWSER_URL', '').value, + writeKey: getNextPublicEnv('NEXT_PUBLIC_JITSU_BROWSER_WRITE_KEY', '').value, // if enabled - events will be sent to the console but no data sent to Jitsu. // Strange this is not mentioned in the documentation https://github.com/jitsucom/jitsu/blob/35c4ecaff54d61a87853381cb17262b7bfbd4a6e/libs/jitsu-js/src/jitsu.ts#L40 echoEvents: false, diff --git a/apps/web/app/services/client/api/employee.ts b/apps/web/app/services/client/api/employee.ts index 54f942a91..127f09a31 100644 --- a/apps/web/app/services/client/api/employee.ts +++ b/apps/web/app/services/client/api/employee.ts @@ -6,7 +6,7 @@ export async function getWorkingEmployeesAPI(tenantId: string, organizationId: s 'where[organizationId]': organizationId, 'relations[0]': 'user' }; - const query = new URLSearchParams(params); + const query = new URLSearchParams(params); const endpoint = process.env.NEXT_PUBLIC_GAUZY_API_SERVER_URL ? `/employee/pagination?${query.toString()}` diff --git a/apps/web/pages/_app.tsx b/apps/web/pages/_app.tsx index 1e5d661c8..5e2b0137e 100644 --- a/apps/web/pages/_app.tsx +++ b/apps/web/pages/_app.tsx @@ -1,5 +1,5 @@ /* eslint-disable no-mixed-spaces-and-tabs */ -import { loadNextPublicEnvs, setNextPublicEnv } from '@app/env'; +import { getNextPublicEnv, loadNextPublicEnvs, setNextPublicEnv } from '@app/env'; import { GA_MEASUREMENT_ID, jitsuConfiguration } from '@app/constants'; import { JitsuProvider } from '@jitsu/jitsu-react'; import { Analytics } from '@vercel/analytics/react'; @@ -85,8 +85,8 @@ const MyApp = ({ Component, pageProps }: AppProps) => { MyApp.getInitialProps = async ({ Component, ctx }: { Component: NextPage; ctx: NextPageContext }) => { // Recover environment variables - const jitsuHost = process.env.NEXT_PUBLIC_JITSU_BROWSER_URL; - const jitsuWriteKey = process.env.NEXT_PUBLIC_JITSU_BROWSER_WRITE_KEY; + const jitsuHost = getNextPublicEnv('NEXT_PUBLIC_JITSU_BROWSER_URL').value; + const jitsuWriteKey = getNextPublicEnv('NEXT_PUBLIC_JITSU_BROWSER_WRITE_KEY').value; const jitsuConf = jitsuConfiguration();