-
Notifications
You must be signed in to change notification settings - Fork 1
[24.12.06 / TASK-48] Refactor - 커스텀 에러 핸들링 추가 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
83 commits
Select commit
Hold shift + click to select a range
dcae0cc
feature: next app init
six-standard b51a5ee
feature: 14로 다운그레이드
six-standard ed901ab
feature: init
six-standard 17c92ab
feature: recovered eslint
six-standard 2cfdfee
refactor: dependencies to devDependencies
six-standard 20c3d9c
modify: pnpm peerdeps 자동 설치
six-standard fedb701
modify: env 무시 추가
six-standard 589f90e
refactor: html lang en -> kr
six-standard 7623ddd
feature: 폰트 적용
six-standard 64101f3
modify: 테스트 일부 수정
six-standard c9eded9
feature: 컬러셋 추가
six-standard 3354be8
modify: bold 폰트만 적용되는 오류 수정
six-standard 8556144
modify: main 페이지 분리
six-standard 4bf80bd
feature: 기본 입력 컴포넌트 추가
six-standard 08f9cc3
feature: 로그인 페이지 퍼블리싱
six-standard 362191e
refactor: gitignore new line 추가
six-standard b40b32e
refactor: 타입스크립트 규칙 추가
six-standard e1b3882
modify: 명령어 변경
six-standard 4b038cc
feature: 필요한 라이브러리 추가
six-standard 2d8affd
modify: readme 적용
six-standard bd43bb4
modify: strict 규칙 추가
six-standard 226e2ff
feature: .env.simple 추가
six-standard 8f7d9c1
feature: 필요한 api 추가 설치
six-standard 6d9f957
modify: 일부 테스트 추가
six-standard 170fa2c
modify: 로그인 페이지 이벤트 일부 적용
six-standard 9c0faf6
refactor: 레이아웃 코드 정리
six-standard 5ad1263
feature: api 인스턴스 정의
six-standard fe862c5
other: feature/init과 merge
six-standard 762cc80
feature: 필요한 라이브러리 추가
six-standard a46e329
feature: Proxy 설정
six-standard dd783b2
modify: readme.md 수정
six-standard 4eaab5c
feature: fetch mock 설정
six-standard f517971
feature: Login Test 제작
six-standard 3517391
modify: Proxy 제거
six-standard aa17e50
feature: queryClient 관련 오류 수정
six-standard 2b7af66
feature: 로그인 페이지 제작
six-standard 5e7683e
modify: SSR / CSR 분리
six-standard 3291549
Merge branch 'main' into feature/login
six-standard dce2bc3
modify: Input 마스킹 처리
six-standard bfa0bbc
modify: Metadata 추가
six-standard 7225fec
modify: 토큰 전달 방식 변경
six-standard a185830
modify: 경로 관련 문제로 삭제
six-standard 9da1f6c
modify: BASE_URL 안정성 강화
six-standard 817b6ea
feature: 임시 요소 제작
six-standard 25d9239
modify: queryClient 옵션 추가
six-standard 8439aef
modify: 필요 없는 test 제거
six-standard f1d0f70
refactor: 네이밍 규칙 일관화
six-standard 48ff0a7
refactor: 필요없는 텍스트 제거
six-standard 1340245
modify: 일부 밀린 커밋 적용
six-standard 360605b
modify: eslint-disable 제거
six-standard a76c825
modify: 네이밍 오타
six-standard bafe062
modify: new line 추가 자동화
six-standard 97cba3f
refactor: 반복된 코드 정리
six-standard 69ac83e
modify: 아직 타임아웃 기능이 없음
six-standard 6959548
modify: include 오류 해결
six-standard ab6f0cf
modify: 컬러 팔레트 이름 변경
six-standard 05310c0
refactor: 절대경로 설정
six-standard c1ee3c1
refactor: prop 타입 관련 오류 해결
six-standard 69555fb
refactor: 메인 페이지 제거
six-standard 69113fe
refactor: import 코드 정리
six-standard 3eaf8a0
refactor: 적절한 경로로 이동
six-standard 7516166
refactor: 코드 리팩토링
six-standard ba46cc1
feature: 서버가 응답하지 않는 케이스 추가
six-standard 6405d65
modify: any 타입 규칙 변경
six-standard abfcf4e
feature: 서버가 응답하지 않을 경우의 처리 추가
six-standard 1e63dc5
refactor: trunk 추가
six-standard 9a7e354
refactor: mutation 오류 처리 방식 변경
six-standard 566eee1
modify: 컬러 팔레트 관련 오류 해결
six-standard 72d016f
modify: 오류 핸들링 관련 코드 추가
six-standard 76e7ed0
feature: 커스텀 에러 추가
six-standard fbd255a
refactor: 네이밍 변경
six-standard 9721a9a
Merge branch 'main' into refactor/all
six-standard 12cd7b1
refactor: 시맨틱 태그로 변경
six-standard ca98243
refactor: ABORT_MS env 값으로 이동
six-standard 930a016
refactor: 오류 명시 변경
six-standard e58f54b
refactor: 타입 정리
six-standard a3ac105
refactor: AbortController 인자 제거
six-standard 577ca43
refactor: 중복 검사 코드 제거
six-standard 7ea45b9
refactor: 코드 스타일과 new line
six-standard 42f0211
refactor: 에러 코드 추가
six-standard 3624118
refactor: import 정리
six-standard 4e736f1
refactor: 커스텀 에러 적용
six-standard e9c338d
refactor: 네이밍 맞춤
six-standard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 +1,2 @@ | ||
NEXT_PUBLIC_BASE_URL=<server's url here> | ||
NEXT_PUBLIC_BASE_URL=<'server url here'> | ||
NEXT_PUBLIC_ABORT_MS=<'abort time(ms) for fetch here'> |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,18 +1,63 @@ | ||
import returnFetch from 'return-fetch'; | ||
import returnFetch, { FetchArgs } from 'return-fetch'; | ||
import { ServerNotRespondingError } from '@/errors'; | ||
|
||
const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL; | ||
const ABORT_MS = Number(process.env.NEXT_PUBLIC_ABORT_MS); | ||
|
||
if (Number.isNaN(ABORT_MS)) { | ||
throw new Error('ABORT_MS가 ENV에서 설정되지 않았습니다'); | ||
} | ||
|
||
if (!BASE_URL) { | ||
throw new Error('BASE_URL가 ENV에서 설정되지 않았습니다.'); | ||
throw new Error('BASE_URL이 ENV에서 설정되지 않았습니다.'); | ||
} | ||
|
||
export const instance = returnFetch({ | ||
type ErrorObject = Record<string, Error>; | ||
|
||
const abortPolyfill = (ms: number) => { | ||
const controller = new AbortController(); | ||
setTimeout(() => controller.abort(), ms); | ||
return controller.signal; | ||
}; | ||
|
||
const fetch = returnFetch({ | ||
baseUrl: BASE_URL, | ||
headers: { Accept: 'application/json' }, | ||
interceptors: { | ||
response: async (response) => { | ||
if (!response.ok) throw response; | ||
return response; | ||
if (!response.ok) { | ||
throw response; | ||
} | ||
return { | ||
...response, | ||
body: response?.text ? JSON.parse(await response?.text()) : {}, | ||
}; | ||
}, | ||
}, | ||
}); | ||
six-standard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export const instance = async ( | ||
input: URL | RequestInfo, | ||
init?: Omit<NonNullable<FetchArgs[1]>, 'body'> & { body: object }, | ||
error?: ErrorObject, | ||
) => { | ||
try { | ||
const data = await fetch(input, { | ||
...init, | ||
body: init?.body ? JSON.stringify(init.body) : undefined, | ||
signal: AbortSignal.timeout | ||
? AbortSignal.timeout(ABORT_MS) | ||
: abortPolyfill(ABORT_MS), | ||
}); | ||
|
||
return data as Awaited<ReturnType<typeof fetch>>; | ||
} catch (err: any) { | ||
if ((err as Error).name === 'TimeoutError') | ||
throw new ServerNotRespondingError(); | ||
else { | ||
if (!error || !(error && error[`${(err as Response).status}`])) | ||
throw new Error(`서버에서 Z 오류가 발생했습니다. (${err.name})`); | ||
throw error[`${(err as Response).status}`]; | ||
} | ||
} | ||
six-standard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Login } from './page'; |
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './(login)'; |
This file contains hidden or 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
This file contains hidden or 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
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use client'; | ||
|
||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { toast } from 'react-toastify'; | ||
import { ReactNode } from 'react'; | ||
|
||
const client = new QueryClient({ | ||
defaultOptions: { | ||
queries: { retry: 1, refetchOnWindowFocus: false }, | ||
mutations: { onError: (err) => toast.error(`${err.message}`) }, | ||
}, | ||
}); | ||
|
||
interface IProp { | ||
children: ReactNode | ReactNode[]; | ||
} | ||
|
||
export const QueryProvider = ({ children }: IProp) => { | ||
return <QueryClientProvider client={client}>{children}</QueryClientProvider>; | ||
}; |
This file contains hidden or 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,2 +1,3 @@ | ||
export * from './Input'; | ||
export * from './QueryProvider'; | ||
export * from './Button'; | ||
export * from './Input'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.