Skip to content

Commit

Permalink
refactor: 환경변수 유틸함수 수정 (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
leeminhee119 authored Mar 13, 2024
1 parent f73c1b1 commit 189938e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/config/environments.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
const { VITE_BASE_URL, VITE_KAKAO_REST_API_KEY, VITE_KAKAO_REDIRECT_URI } = import.meta.env;

export const environments = {
baseUrlEnv: () => checkEnv(VITE_BASE_URL),
kakaoRestApiKeyEnv: () => checkEnv(VITE_KAKAO_REST_API_KEY),
kakaoRedirectUriEnv: () => checkEnv(VITE_KAKAO_REDIRECT_URI),
baseUrlEnv: () => getEnvVariable('VITE_BASE_URL'),
kakaoRestApiKeyEnv: () => getEnvVariable('VITE_KAKAO_REST_API_KEY'),
kakaoRedirectUriEnv: () => getEnvVariable('VITE_KAKAO_REDIRECT_URI'),
};

const checkEnv = (envKey: string) => {
if (!envKey) {
const getEnvVariable = (envKey: string) => {
const envVariable = import.meta.env[envKey];
if (!envVariable) {
throw new Error(`${envKey} 환경변수가 설정돼있지 않습니다.`);
}
return envKey;
return envVariable;
};

0 comments on commit 189938e

Please sign in to comment.