Skip to content

Commit

Permalink
Turnstile
Browse files Browse the repository at this point in the history
Remove .env
  • Loading branch information
BriianPowell committed Nov 1, 2023
1 parent fbbcc21 commit aaad0c4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/assets/utils/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export function getEnv(name: string) {
const value = process.env[name];

if (!value) {
throw new Error(`Missing environment variable: ${name}`);
}

return value;
}
3 changes: 2 additions & 1 deletion src/components/contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import contactStyles from 'css/contact.module.scss';
import sharedStyles from 'css/shared.module.scss';
import { IFormikContext, IPersonalData, WidgetStatus } from 'types/index';
import { useAppContext } from 'utils/AppContextProvider';
import { getEnv } from 'utils/env';

export const Contact: FC<IPersonalData> = () => {
const { isLoaded } = useLoadScript({
id: 'collective-map-script',
googleMapsApiKey: process.env.NEXT_PUBLIC_MAPS_API_KEY!,
googleMapsApiKey: getEnv(MAPS_API_KEY_NAME),
});

const mapCenter = useMemo(() => ({ lat: 33.660057, lng: -117.99897 }), []);
Expand Down
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const MAPS_API_KEY_NAME = 'NEXT_PUBLIC_MAPS_API_KEY';
export const FORMS_API_KEY_NAME = 'NEXT_PUBLIC_FORMS_KEY';
export const RECAPTCHA_SITE_KEY_NAME = 'NEXT_PUBLIC_RECAPTCHA_SITE_KEY';
export const TURNSTILE_SITE_KEY_NAME = 'NEXT_PUBLIC_TURNSTILE_SITE_KEY';

0 comments on commit aaad0c4

Please sign in to comment.