Skip to content

Commit 8bb45d5

Browse files
committed
🚑 handle type error and .env empty in build time
1 parent f63734d commit 8bb45d5

File tree

5 files changed

+39
-12
lines changed

5 files changed

+39
-12
lines changed

core/storeRegistrationService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const makeBusinessHourData = (
3737
refArr: MutableRefObject<Array<RefObject<HTMLButtonElement>> | null[] | HTMLButtonElement[]>,
3838
selectedBusinessHourBtn: string,
3939
) => {
40-
const businessHourArr = [];
40+
const businessHourArr: Array<{ day: string; time: string }> = [];
4141
if (selectedBusinessHourBtn === 'weekDaysWeekEnd') {
4242
for (let i = 0; i < 5; i++) {
4343
businessHourArr.push({ day: businessHourDays[i].day, time: (refArr.current[0] as HTMLButtonElement).value });

next.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ const nextConfig = {
2828
})
2929
return config
3030
},
31+
env: {
32+
NTS_API_BASE_URL: process.env.NTS_API_BASE_URL,
33+
NTS_API_KEY: process.env.NTS_API_KEY,
34+
S3_UPLOAD_KEY: process.env.S3_UPLOAD_KEY,
35+
S3_UPLOAD_URL: process.env.S3_UPLOAD_URL,
36+
S3_UPLOAD_SECRET: process.env.S3_UPLOAD_SECRET,
37+
S3_UPLOAD_BUCKET: process.env.S3_UPLOAD_BUCKET,
38+
S3_UPLOAD_REGION: process.env.S3_UPLOAD_REGION,
39+
API_BASE_URL: process.env.API_BASE_URL,
40+
KAKAO_CLIENT_ID: process.env.KAKAO_CLIENT_ID,
41+
KAKAO_CLIENT_SECRET: process.env.KAKAO_CLIENT_SECRET,
42+
KAKAO_MAP_REST_KEY: process.env.KAKAO_MAP_REST_KEY,
43+
NAVER_CLIENT_ID: process.env.NAVER_CLIENT_ID,
44+
NAVER_CLIENT_SECRET: process.env.NAVER_CLIENT_SECRET,
45+
BASE_URL: process.env.BASE_URL,
46+
}
3147
};
3248

3349
module.exports = nextConfig;

store/actions/modalStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const MODAL_KEY = {
2424
} as const;
2525

2626
export const modalStore = (set) => ({
27-
modalKey: MODAL_KEY.OFF,
27+
modalKey: 'OFF',
2828
changeModalKey: (changedModalKey: string) => set(() => ({ modalKey: changedModalKey })),
2929
});
3030

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"isolatedModules": true,
1616
"jsx": "preserve",
1717
"incremental": true,
18+
"noImplicitAny": false,
1819
"plugins": [
1920
{
2021
"name": "next"

utils/storage.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,35 @@ export const setUserSession = (accessToken: string, refreshToken: string) => {
2626
};
2727

2828
export const clearUserSession = () => {
29-
sessionStorage.removeItem(STORAGE_KEY.TOKEN);
30-
sessionStorage.removeItem(STORAGE_KEY.REFRESH_TOKEN);
29+
if (typeof window !== 'undefined') {
30+
sessionStorage.removeItem(STORAGE_KEY.TOKEN);
31+
sessionStorage.removeItem(STORAGE_KEY.REFRESH_TOKEN);
32+
}
3133
};
3234

3335
export const setUserTokenInLocalStorage = (token?: string, refreshToken?: string) => {
34-
if (token) {
35-
localStorage.setItem(STORAGE_KEY.TOKEN, token);
36-
}
36+
if (typeof window !== 'undefined') {
37+
if (token) {
38+
localStorage.setItem(STORAGE_KEY.TOKEN, token);
39+
}
3740

38-
if (refreshToken) {
39-
localStorage.setItem(STORAGE_KEY.REFRESH_TOKEN, refreshToken);
41+
if (refreshToken) {
42+
localStorage.setItem(STORAGE_KEY.REFRESH_TOKEN, refreshToken);
43+
}
4044
}
4145
};
4246

4347
export const removeUserTokenInLocalStorage = () => {
44-
localStorage.removeItem(STORAGE_KEY.TOKEN);
45-
localStorage.removeItem(STORAGE_KEY.REFRESH_TOKEN);
48+
if (typeof window !== 'undefined') {
49+
localStorage.removeItem(STORAGE_KEY.TOKEN);
50+
localStorage.removeItem(STORAGE_KEY.REFRESH_TOKEN);
51+
}
4652
};
4753

4854
export const getUserTokenFromLocalStorage = () => {
49-
return localStorage.getItem(STORAGE_KEY.TOKEN) ?? '';
55+
if (typeof window !== 'undefined') {
56+
return localStorage.getItem(STORAGE_KEY.TOKEN);
57+
}
58+
59+
return '';
5060
};

0 commit comments

Comments
 (0)