-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor/client api caller #63
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git โ๏ธ
|
Walkthrough์ด ํ ๋ฆฌํ์คํธ๋ ํด๋ผ์ด์ธํธ์ ์๋ฒ ์ธก์์ ๋ก๊ทธ์ธ, ํ์๊ฐ์
๋ฐ API ์์ฒญ ์ฒ๋ฆฌ ๋ฐฉ์์ ๋ฆฌํฉํ ๋งํฉ๋๋ค. ๋ก๊ทธ์ธ๊ณผ ํ์๊ฐ์
ํ์ด์ง์์๋ axios ํธ์ถ ๋์ ๊ฐ๊ฐ Changes
Sequence Diagram(s)sequenceDiagram
participant User as ์ฌ์ฉ์
participant LoginPage as ๋ก๊ทธ์ธ ํ๋ฉด
participant SignInAPI as signIn ํจ์
participant Jwt as JWT ์ ํธ๋ฆฌํฐ
participant LocalStorage as ๋ก์ปฌ ์คํ ๋ฆฌ์ง
User->>LoginPage: ๋ก๊ทธ์ธ ์ ๋ณด ์
๋ ฅ (์ด๋ฉ์ผ, ๋น๋ฐ๋ฒํธ)
LoginPage->>SignInAPI: signIn ํธ์ถ
SignInAPI-->>LoginPage: ์๋ต (accessToken)
LoginPage->>Jwt: Jwt.fromString(accessToken) ํธ์ถ
Jwt-->>LoginPage: ํ ํฐ ๊ฐ์ฒด ๋ฐํ
LoginPage->>LocalStorage: token.storeToLocalStorage() ์คํ
LoginPage->>User: ๋ก๊ทธ์ธ ์ฑ๊ณต ์ฒ๋ฆฌ
sequenceDiagram
participant User as ์ฌ์ฉ์
participant SignupPage as ํ์๊ฐ์
ํ๋ฉด
participant SignUpAPI as signUp ํจ์
participant Debug as debugPrint ํจ์
User->>SignupPage: ํ์๊ฐ์
์ ๋ณด ์
๋ ฅ
SignupPage->>SignUpAPI: signUp ํธ์ถ
SignUpAPI-->>SignupPage: ์๋ต (user id)
SignupPage->>Debug: debugPrint(user id) ์คํ
SignupPage->>User: ํ์๊ฐ์
์๋ฃ ์๋ต
โจ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? ๐ชง TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
๐งน Nitpick comments (12)
client/src/utils/apis/common.ts (5)
1-5
: ํ๊ฒฝ ๋ถ๋ฆฌ์ ๋ํ ๊ณ ๋ ค ๊ถ์ฅ
BASE_URL์ด ํ๋์ฝ๋ฉ๋์ด ์์ด, ํ๋ก๋์ /๊ฐ๋ฐ ํ๊ฒฝ๋ณ๋ก ๋ค๋ฅธ URL์ ์ ์ฉํ๊ธฐ ์ด๋ ค์ธ ์ ์์ต๋๋ค. ํ๊ฒฝ ๋ณ์๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ์์ ๊ณ ๋ คํด ๋ณด์ธ์.
23-51
: ์๋ฌ ์ ์ฉ ํด๋์ค ์ธ๋ถํ
400~500๋ ์๋ฌ๋ฅผ ๊ตฌ์ฒด์ ์ผ๋ก ๊ตฌ๋ถํด ๊ฐ๋ ์ฑ์ด ์ข์์ก์ต๋๋ค. ๋ค๋ง ๊ณตํต ๋ก์ง์ด ๋ฐ๋ณต๋๋ฏ๋ก, ํ์ํ ๊ฒฝ์ฐ ์์ฑ์ ๋ก์ง์ ์ถ์ํํด ์ค๋ณต์ ์ค์ผ ์๋ ์์ต๋๋ค.
90-109
: getContentType ํจ์ ๊ตฌ์กฐ
headers
๋ฐฐ์ด์ ์ํํ์ฌ Content-Type์ ํ๋ณํ๋ ๋ก์ง์ด ๋ช ํํฉ๋๋ค. ์ถํ Content-Type ์ ํ์ด ๋ ๋์ด๋ ๊ฒฝ์ฐ๋ฅผ ๋๋นํด ํ์ฅ ๊ฐ๋ฅํ๋๋ก switch๋ ๋งคํ ๊ตฌ์กฐ๋ฅผ ๋์ ํ๋ ๊ฒ๋ ๊ณ ๋ คํด ๋ณด์ธ์.
111-127
: getResponseContentType ํจ์ ๋ด ์ฝ์ ์ถ๋ ฅ
๊ฐ๋ฐ ๊ณผ์ ์์ ์ ๋ณด๋ฅผ ํ์ธํ๊ธฐ ์ํดconsole.log
๊ฐ ์ฌ์ฉ๋๊ณ ์์ต๋๋ค. ํ๋ก๋์ ํ๊ฒฝ์์๋ ์ ๊ฑฐํ๊ฑฐ๋ ๋ก๊น ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก ๋์ฒดํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
129-213
: inner ๋ฉ์๋์ ์์ธ ์ฒ๋ฆฌ ๋ก์ง
HTTP ์ํ ์ฝ๋๋ณ๋ก ์ ์ ํ ์ปค์คํ ์์ธ ํด๋์ค๋ฅผ ๋์ ธ์ ์์ธก ๊ฐ๋ฅํ ์๋ฌ ํ๋ฆ์ด ํ๋ณด๋์์ต๋๋ค. ๋ค๋ง, ์๋ฒ์์ ์ ๋ฌํ ์๋ฌ ๋ฉ์์ง๋ ์์ธ ์ ๋ณด๊ฐ ์๋ค๋ฉด ํจ๊ป ํฌํจํด ์ฃผ๋ฉด ๋๋ฒ๊น ์ ์ ์ตํ ์ ์์ต๋๋ค.client/src/utils/apis/accounts.ts (3)
1-3
: ๋ถํ์ํ ๊ณต๋ฐฑ ๋ผ์ธ ํ์ธ
์ค๋ฐ๊ฟ์ด ์ฆ์ ํ์ผ์ด ์กฐ๊ธ ์ด์์ ํด ๋ณด์ผ ์ ์์ต๋๋ค. ํ์ ์๋ ๊ณต๋ฐฑ์ ์ค์ด๋ ํธ์ด ๊ฐ๋ ์ฑ์ ์ ๋ฆฌํฉ๋๋ค.
14-18
: kakaoSignIn ํจ์
์นด์นด์ค ๋ก๊ทธ์ธ ์์ฒญ ํํ์ signIn ํจ์ ๋ก์ง์ด ์ ์ฌํ๊ฒ ๊ตฌ์ฑ๋์์ต๋๋ค. ๊ณตํต ๋ก์ง์ ํฉ์น๋ ๋ฐฉ๋ฒ๋ ๊ณ ๋ คํ ์ ์์ง๋ง, ํ์ฌ ํํ๋ ๋ช ํํด ์ ์ง๋ณด์ํ๊ธฐ ์ฉ์ดํฉ๋๋ค.
26-31
: signUp ํจ์
๊ณ์ ์์ฑ ์์ฒญ์ดPOST
๋ก ์ ์ค์ ๋์์ผ๋ฉฐ Content-Type๋ JSON์ผ๋ก ์ง์ ๋์์ต๋๋ค. ์ถํ ํ์๊ฐ์ ์๋๋ฆฌ์ค์์ ์ค๋ณต ์ด๋ฉ์ผ ์ฒ๋ฆฌ ๋ฑ์ ์ํฉ์ ์ฃผ์ ๊น๊ฒ ํ ์คํธํด ๋ณด์ธ์.client/src/utils/apis/token.ts (3)
12-19
: JWT ์ง๋ ฌํ ๋ก์ง
btoa(JSON.stringify(...))
๋ฅผ ํตํด ๋ฌธ์์ด๋ก ๋ณํํ๋ ๊ณผ์ ์ด ๊ฐ๋จ๋ช ๋ฃํฉ๋๋ค. ํ์ํ ๊ฒฝ์ฐ ๋ก๊น ์ ๋ฏผ๊ฐ ๋ฐ์ดํฐ๊ฐ ๋ ธ์ถ๋์ง ์๋๋ก ์ฃผ์๊ฐ ํ์ํฉ๋๋ค.
24-27
: storeToLocalStorage ์ฌ์ฉ
ํ๊ฒฝ์ ๋ฐ๋ผ ์ธ์ ์คํ ๋ฆฌ์ง ๋ฑ์ ์ ํ๋ ๊ณ ๋ คํ ์ ์์ต๋๋ค. ํ ๋ก์ปฌ ์คํ ๋ฆฌ์ง ๋ก์ง์ ๊ฐ๋จํด ๋ณด์ด์ง๋ง, ๋ณด์ ๊ด์ ์์ ํ ํฐ ํ์ทจ ์ํ์ด ์์์ ์ธ์งํ์ ์ผ ํฉ๋๋ค.
28-36
: fromString ์๋ฌ ์ฒ๋ฆฌ
JWT ํ์ฑ์ ์คํจํ๋ฉด null์ ๋ฐํํ์ฌ ์์ ๋ก์ง์์ ๋ถ๊ธฐ ์ฒ๋ฆฌ๊ฐ ๊ฐ๋ฅํด์ง๋๋ค. ํ์ํ๋ค๋ฉด ๊ตฌ์ฒด์ ์ธ ์์ธ ์ฒ๋ฆฌ๋ฅผ ํตํด ์๋ฌ ์์ธ๋ ํจ๊ป ํ์ ํ ์ ์๋๋ก ๊ฐ์ ํ ์ ์์ต๋๋ค.client/src/pages/index.tsx (1)
38-46
: ๋ก๊ทธ์ธ ๋ก์ง ๊ฐ์JWT ํ ํฐ ์ฒ๋ฆฌ์ ์ ์ฅ์ด ๋ ์์ ํ๊ณ ์ฒด๊ณ์ ์ผ๋ก ๊ตฌํ๋์์ต๋๋ค. ํ์ง๋ง ํ ํฐ ๊ฒ์ฆ ๊ณผ์ ์ด ์ถ๊ฐ๋๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ํ ํฐ ๊ฒ์ฆ ๋ก์ง์ ์ถ๊ฐํ๋ ๊ฒ์ ๊ณ ๋ คํด๋ณด์ธ์:
let { accessToken } = await signIn({ email, password }); let token = Jwt.fromString(accessToken)!; + if (!token.isValid()) { + throw new Error('Invalid token received'); + } debugPrint("accessToken:", accessToken); token.storeToLocalStorage();
๐ Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
๐ Files selected for processing (8)
client/src/pages/index.tsx
(2 hunks)client/src/pages/signup/index.tsx
(2 hunks)client/src/utils/apis/accounts.ts
(1 hunks)client/src/utils/apis/common.ts
(1 hunks)client/src/utils/apis/token.ts
(1 hunks)client/src/utils/debug.ts
(0 hunks)client/tsconfig.json
(1 hunks)server/src/utils/debug.ts
(0 hunks)
๐ค Files with no reviewable changes (2)
- server/src/utils/debug.ts
- client/src/utils/debug.ts
๐ Additional comments (14)
client/src/utils/apis/common.ts (4)
6-21
: HttpException ํด๋์ค ๊ตฌํ ํ์ธ
์๋ฌ ๋ฉ์์ง๋ฅผ ๊ฐ๊ฒฐํ๊ณ ๋ช ํํ๊ฒ ํํํ๊ณ ์์ด ์ ์ง๋ณด์์ ์ ๋ฆฌํฉ๋๋ค. ์ถํ ๋ค์ํ ์๋ฌ ๋ก๊น ์ฒ๋ฆฌ๋ฅผ ์ํด ๋ก๊น ์ธํฐํ์ด์ค ์ถ๊ฐ๋ ๊ณ ๋ คํ ์ ์์ต๋๋ค.
53-78
: ApiBuilder ๊ธฐ๋ณธ ์ต์ ๊ตฌ์ฑ ์ ๊ฒ
private
ํ๋๋ก URL, method, headers๋ฅผ ๊น๋ํ๊ฒ ๊ด๋ฆฌํ๊ณ ์์ผ๋ฉฐ, ๋ฉ์๋ ์ฒด์ด๋ ๊ตฌ์กฐ๊ฐ ์ง๊ด์ ์ ๋๋ค. ๋ค๋ง ์์ฒญ์ด ๋ง์์ง ๊ฒฝ์ฐ๋ฅผ ๋๋นํด, ๊ณตํต ํค๋(์: JSON ๋ฑ)๋ฅผ ์๋ ์ค์ ํ๋ ์ ํธ๋ฆฌํฐ ์ถ๊ฐ๋ ๊ฒํ ๊ฐ๋ฅํฉ๋๋ค.
79-89
: commit ๋ฐ commitWithParams ์ค๊ณ
์๋ฌ ์ฒ๋ฆฌ๋ฅผ ์ํ ๊ณตํต ๋ก์ง์ ๋ด๋ถ static ๋ฉ์๋๋ก ๋ถ๋ฆฌํด ์ฌ์ฌ์ฉ์ด ์ ๊ตฌํ๋์์ต๋๋ค. ํ๋ผ๋ฏธํฐ๊ฐ ํ์ํ ๊ฒฝ์ฐ์ ์๋ ๊ฒฝ์ฐ๋ฅผ ๋ถ๋ฆฌํ๋ ์์ด๋์ด๊ฐ ๋ช ํํฉ๋๋ค.
215-229
: ApiBuilder2 ํด๋์ค์ ์ฉ๋ ๋ถ๋ช ํ
ApiBuilder์ ์ ์ฌํ์ง๋ง ๊ธฐ๋ฅ์ด ์ ํ์ ์ด์ด์ ์ค์ ์ฌ์ฉ ์ฌ๋ก๊ฐ ๋ช ํํ์ง ์์ ๋ณด์ ๋๋ค. ํ์ํ๋ค๋ฉด ApiBuilder์ ํตํฉํ๊ฑฐ๋, ์ค์ฌ์ฉ ์ ํ์ฅ ๊ฐ๋ฅํ๋๋ก ๋ก์ง์ ์ ๋นํด ๋ณด์ธ์.client/src/utils/apis/accounts.ts (4)
4-5
: ์์ฒญ/์๋ต DTO ์ ์
ํ์ ์ผ๋ก DTO๋ฅผ ๊ตฌ์กฐํํด ์ฝ๋ ๊ฐ๋ ์ฑ๊ณผ ์ ์ง๋ณด์์ฑ์ด ์ข์์ก์ต๋๋ค. ๊ฐ ํ๋๊ฐ ํ์/์ต์ ์ธ์ง ๋ช ํํ ๋๋ฌ๋ ์ข์ต๋๋ค.
6-10
: signIn ํจ์ - API ๊ฒฝ๋ก์ ์ค์
"accounts/signin"
์ผ๋ก POST ํธ์ถ์ ์ํํ๊ณ , JSON Content-Type ์ง์ ์ด ์ ์ ํฉ๋๋ค. ์๋ฌ ์ฒ๋ฆฌ ์ ๋ด๋ถ์ ์ผ๋ก Custom Exception์ด ๋์ ธ์ง๋ฏ๋ก, ํธ์ถ ์ชฝ์์ ์์ธ ํธ๋ค๋ง ๋ก์ง์ด ํ์ํฉ๋๋ค.
12-13
: KakaoSignInReqDto, KakaoSignInResDto ์ ์
์นด์นด์ค ์ธ์ฆ์ด ๊ธฐ์กด SignInResDto ํ์ ์ ์ฌํ์ฉํด ๋ฐํ ํ์ ์ ์ง๊ฐ ๊ฐ๊ฒฐํฉ๋๋ค. ํ์ ์ ์นด์นด์ค ํนํ ํ๋๊ฐ ์ถ๊ฐ๋ ์ ์์ผ๋ ํ์ฅ ๊ฐ๋ฅ์ฑ์ ์ผ๋์ ๋๋ฉด ์ข๊ฒ ์ต๋๋ค.
20-25
: SignUpReqDto ๊ตฌ์กฐ
Optional ํ๋(profileUrl
)๋ฅผ ๋ช ํํ ํ์ํด์ค์ ์ข์ต๋๋ค. ์ด ํ๋๊ฐ nullableํ์ง, ๋น ๋ฌธ์์ด์ธ์ง์ ๋ํ ์ฒ๋ฆฌ๋ ์ฌ์ฉํ๋ ์ชฝ์์ ์ฃผ์๊ฐ ํ์ํ๊ฒ ์ต๋๋ค.client/src/utils/apis/token.ts (3)
1-2
: debugPrint ์ํฌํธ
๋๋ฒ๊ทธ์ฉ ์ถ๋ ฅ์ด ์ ๋ถ๋ฆฌ๋์ด ์์ต๋๋ค. ํ๋ก๋์ ํ๊ฒฝ์์๋ ๋ฏผ๊ฐ ์ ๋ณด๊ฐ ๋ ธ์ถ๋์ง ์๋๋ก ์ฃผ์ํด ์ฃผ์ธ์.
3-11
: Jwt ํด๋์ค ๊ตฌ์กฐ
LS_KEY
์์๋ฅผ ์ฌ์ฉํด ๋ก์ปฌ ์คํ ๋ฆฌ์ง ํค๊ฐ ๋ช ํํ๊ฒ ๊ด๋ฆฌ๋๊ณ , JWT ํค๋, ํ์ด๋ก๋, ์๋ช ์ ๋ถํ ํ์ฌ ๋ณด๊ดํ๋ ๊ตฌ์กฐ๊ฐ ๊ธฐ๋ฅ์ ์ผ๋ก ๊น๋ํฉ๋๋ค.
38-47
: fromLocalStorage ๋ฉ์๋
ํ ํฐ์ด ์์ ๋ debugPrint๋ฅผ ํตํด ์ฌ์ ๋ฅผ ์ฝ์์ ๋จ๊ธฐ๋ ๋ฐฉ์์ด ์ ์ฉํฉ๋๋ค. ์ถํ ํ๋ก๋์ ํ๊ฒฝ์์ ๋ฏผ๊ฐ ์ ๋ณด ๋ ธ์ถ ์ํ์ด ์๋๋ก ์กฐ์ ํด ์ฃผ์ธ์.client/src/pages/index.tsx (1)
4-7
: API ํธ์ถ ๋ฐ ์๋ฌ ์ฒ๋ฆฌ๋ฅผ ์ํ ์ ํธ๋ฆฌํฐ ์ถ๊ฐ์๋ก์ด ์ ํธ๋ฆฌํฐ๋ค์ ํตํด API ํธ์ถ๊ณผ ์๋ฌ ์ฒ๋ฆฌ๊ฐ ๋ ์ฒด๊ณ์ ์ผ๋ก ๊ตฌ์กฐํ๋์์ต๋๋ค.
client/src/pages/signup/index.tsx (1)
5-7
: ํ์๊ฐ์ API ์ ํธ๋ฆฌํฐ ์ถ๊ฐAPI ํธ์ถ๊ณผ ์๋ฌ ์ฒ๋ฆฌ๋ฅผ ์ํ ์ ํธ๋ฆฌํฐ๊ฐ ์ ์ ํ ์ถ๊ฐ๋์์ต๋๋ค.
client/tsconfig.json (1)
12-12
:โ Verification inconclusive
๋ชจ๋ ํด๊ฒฐ ์ ๋ต ๋ณ๊ฒฝ ๊ฒํ ํ์
moduleResolution
์ "node10"์ผ๋ก ๋ณ๊ฒฝํ ๊ฒ์ด ํ๋ก์ ํธ์ ๋ค๋ฅธ ๋ถ๋ถ์ ์ํฅ์ ๋ฏธ์น ์ ์์ต๋๋ค.๋ค์ ์น ๊ฒ์์ ํตํด ์ด ๋ณ๊ฒฝ์ ์ํฅ์ ํ์ธํด์ฃผ์ธ์:
๐ Web query:
What are the implications of changing TypeScript moduleResolution to "node10"?
๐ก Result:
Changing TypeScript's
moduleResolution
to"node10"
has several implications tied to outdated Node.js compatibility and modern ecosystem limitations:Key Implications
CommonJS-Only Resolution
node10
mimics Node.js <v10 environments, which only support CommonJSrequire
-style imports[1][9]. It lacks native ECMAScript module (ESM) import/export resolution algorithms used in Node.js โฅv12[1][5].No Package.json
"exports"
Support
Unlike modern resolutions (node16
,nodenext
,bundler
),node10
ignorespackage.json
exports maps[4][7]. Subpath imports likeimport 'pkg/subpath'
will fail unless packages provide explicit legacy directory listings[4].File Extension Requirements
Imports must include full file extensions (.js
,.ts
) for relative/absolute paths[1][7], unlikebundler
mode which allows extensionless imports[1].Deprecated Naming Confusion
Previously called"node"
, this option was renamed to"node10"
for clarity[6][9]. Projects using older TS versions might still see references to the original name.When You Might Use It
- Maintaining codebases targeting Node.js โคv9 (EOL since 2019)
- Working with dependencies that haven't adopted
package.json
exports[4]- Debugging legacy systems where upgrading dependencies/modern resolution isn't feasible
Modern Alternatives
Strategy Best For Key Features nodenext
Node.js โฅv12 Full ESM/CJS hybrid resolution[1][3] bundler
Webpack/Rollup/Vite Relaxed extension rules + exports support[1][5] node16
TypeScript 5.3+ Explicit Node.js ESM semantics[1][3] Most projects should migrate to
bundler
ornodenext
unless explicitly maintaining legacy environments[1][5][7]. The--moduleResolution node10
flag primarily exists for backward compatibility rather than new development[9].Citations:
- 1: https://www.typescriptlang.org/tsconfig/moduleResolution.html
- 2: https://www.typescriptlang.org/docs/handbook/2/modules.html
- 3: https://devblogs.microsoft.com/typescript/announcing-typescript-5-3/
- 4: https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/NoResolution.md
- 5: https://github.com/IanVS/ts-module-resolution-examples
- 6: microsoft/TypeScript#51714
- 7: https://www.youtube.com/watch?v=MEl2R7mEAP8
- 8: https://www.scaler.com/topics/typescript/module-resolution-strategies-in-typescript/
- 9: https://www.tslang.com.cn/tsconfig/
- 10: https://typescript-v2-121.ortam.vercel.app/docs/handbook/module-resolution.html
๋ชจ๋ ํด๊ฒฐ ์ ๋ต ์ํฅ ์ฌ๊ฒํ ์์ฒญ
ํ์ฌ
client/tsconfig.json
ํ์ผ์์"moduleResolution": "node10"
์ผ๋ก ์ค์ ํ ๋ณ๊ฒฝ์ ์๋์ ๊ฐ์ ์ํฅ์ ๋ฏธ์น ์ ์์ต๋๋ค:
CommonJS ์ ์ฉ ํด์:
node10
์ Node.js v10 ๋ฏธ๋ง์ ํ๊ฒฝ์ ๋ชจ๋ฐฉํ์ฌ CommonJS ์ ์ฉ ํด์ ๋ฐฉ์์ ์ฌ์ฉํฉ๋๋ค. ์ต์ ESM(import/export) ์ง์์ด ํ์ํ ํ๊ฒฝ์์๋ ํธํ์ฑ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค.package.json์ exports ๋ฏธ์ง์:
์ต์ ๋ชจ๋ ํด์ ์ต์ (node16
,nodenext
,bundler
)๊ณผ ๋ฌ๋ฆฌ,"node10"
์package.json
๋ด์"exports"
ํ๋๋ฅผ ๋ฌด์ํฉ๋๋ค. ์ด๋ก ์ธํด ํ์ ๊ฒฝ๋ก(import 'pkg/subpath') ์ฌ์ฉ ์ ๋ฌธ์ ๋ฐ์ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค.ํ์ผ ํ์ฅ์ ์๊ตฌ ์ฆ๊ฐ:
์๋/์ ๋ ๊ฒฝ๋ก์ ๋ชจ๋ ์ํฌํธ ์ ํ์ผ์ ํ์ฅ์(.js
,.ts
)๋ฅผ ๋ช ์์ ์ผ๋ก ํฌํจํด์ผ ํ๋ ์ ํ์ด ์์ต๋๋ค.๋ฐ๋ผ์, ํ๋ก์ ํธ์ ๋ชจ๋ ํด์ ์ ๋ต์ด ์ต์ Node.js ํ๊ฒฝ์ด๋ ์ธ๋ถ ํจํค์ง์์ ํธํ์ฑ์ ํ์๋ก ํ๋ ๊ฒฝ์ฐ,
node10
์ฌ์ฉ์ด ์ ํฉํ์ง ์ฌ๊ฒํ ํ๊ณ , ํ์์ ๋ฐ๋ผnodenext
,bundler
๋๋node16
๋ฑ ๋ค๋ฅธ ์ต์ ์ ๊ณ ๋ คํด๋ณด์๊ธฐ ๋ฐ๋๋๋ค.
} catch (e) { | ||
if (e instanceof BadRequestException) { | ||
alert('bad request'); | ||
} else if (e instanceof NotFoundException) { | ||
alert('no such account'); | ||
} else { | ||
console.error('unknown error >', e); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐ ๏ธ Refactor suggestion
์๋ฌ ์ฒ๋ฆฌ ๊ฐ์
์๋ฌ ๋ฉ์์ง๊ฐ ์ฌ์ฉ์ ์นํ์ ์ด์ง ์์ต๋๋ค. ๋ ์์ธํ ์๋ฌ ๋ฉ์์ง๋ฅผ ์ ๊ณตํ๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค.
๋ค์๊ณผ ๊ฐ์ด ์๋ฌ ๋ฉ์์ง๋ฅผ ๊ฐ์ ํ๋ ๊ฒ์ ์ถ์ฒ๋๋ฆฝ๋๋ค:
} catch (e) {
if (e instanceof BadRequestException) {
- alert('bad request');
+ alert('์
๋ ฅํ์ ์ ๋ณด๋ฅผ ๋ค์ ํ์ธํด์ฃผ์ธ์.');
} else if (e instanceof NotFoundException) {
- alert('no such account');
+ alert('๋ฑ๋ก๋์ง ์์ ๊ณ์ ์
๋๋ค. ํ์๊ฐ์
์ ์งํํด์ฃผ์ธ์.');
} else {
console.error('unknown error >', e);
+ alert('๋ก๊ทธ์ธ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. ์ ์ ํ ๋ค์ ์๋ํด์ฃผ์ธ์.');
}
}
๐ Committable suggestion
โผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
} catch (e) { | |
if (e instanceof BadRequestException) { | |
alert('bad request'); | |
} else if (e instanceof NotFoundException) { | |
alert('no such account'); | |
} else { | |
console.error('unknown error >', e); | |
} | |
} catch (e) { | |
if (e instanceof BadRequestException) { | |
alert('์ ๋ ฅํ์ ์ ๋ณด๋ฅผ ๋ค์ ํ์ธํด์ฃผ์ธ์.'); | |
} else if (e instanceof NotFoundException) { | |
alert('๋ฑ๋ก๋์ง ์์ ๊ณ์ ์ ๋๋ค. ํ์๊ฐ์ ์ ์งํํด์ฃผ์ธ์.'); | |
} else { | |
console.error('unknown error >', e); | |
alert('๋ก๊ทธ์ธ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. ์ ์ ํ ๋ค์ ์๋ํด์ฃผ์ธ์.'); | |
} |
const handleSignupClick = async () => { | ||
const url = `${process.env.NEXT_PUBLIC_BASE_URL}/api/v1/accounts/signup`; | ||
console.log(url); | ||
|
||
try { | ||
await axios.post( | ||
url!, | ||
{ | ||
email, | ||
nickname, | ||
password, | ||
profileUrl, | ||
}, | ||
{ | ||
headers: { | ||
"Content-Type": "application/json" | ||
} | ||
} | ||
); | ||
let { id: uid } = await signUp({ email, nickname, password, profileUrl }); | ||
debugPrint('uid:', uid); | ||
|
||
router.push('/'); | ||
} catch(e) { | ||
if (axios.isAxiosError(e)) { | ||
if (e.response?.status === 400) { | ||
alert('bad request'); | ||
} else { | ||
alert('unknown error'); | ||
} | ||
} catch (e) { | ||
if (e instanceof BadRequestException) { | ||
alert('bad request'); | ||
} else { | ||
console.error('unknown error >', e); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐ ๏ธ Refactor suggestion
ํ์๊ฐ์ ๋ก์ง ๋ฐ ์๋ฌ ์ฒ๋ฆฌ ๊ฐ์ ํ์
ํ์๊ฐ์ ์ฑ๊ณต ์ ์ฌ์ฉ์ ํผ๋๋ฐฑ์ด ์์ผ๋ฉฐ, ์๋ฌ ๋ฉ์์ง๊ฐ ๋ถ์น์ ํฉ๋๋ค. ๋ํ ์ ๋ ฅ๊ฐ ๊ฒ์ฆ์ด ๋ถ์กฑํฉ๋๋ค.
๋ค์๊ณผ ๊ฐ์ ๊ฐ์ ์ ์ ์๋๋ฆฝ๋๋ค:
const handleSignupClick = async () => {
+ if (password.length < 8) {
+ alert('๋น๋ฐ๋ฒํธ๋ 8์ ์ด์์ด์ด์ผ ํฉ๋๋ค.');
+ return;
+ }
try {
let { id: uid } = await signUp({ email, nickname, password, profileUrl });
debugPrint('uid:', uid);
+ alert('ํ์๊ฐ์
์ด ์๋ฃ๋์์ต๋๋ค. ๋ก๊ทธ์ธ ํ์ด์ง๋ก ์ด๋ํฉ๋๋ค.');
router.push('/');
} catch (e) {
if (e instanceof BadRequestException) {
- alert('bad request');
+ alert('์
๋ ฅํ์ ์ ๋ณด๋ฅผ ๋ค์ ํ์ธํด์ฃผ์ธ์. ์ด๋ฉ์ผ ํ์์ด ์ฌ๋ฐ๋ฅธ์ง ํ์ธํด์ฃผ์ธ์.');
} else {
console.error('unknown error >', e);
+ alert('ํ์๊ฐ์
์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. ์ ์ ํ ๋ค์ ์๋ํด์ฃผ์ธ์.');
}
}
};
๐ Committable suggestion
โผ๏ธ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const handleSignupClick = async () => { | |
const url = `${process.env.NEXT_PUBLIC_BASE_URL}/api/v1/accounts/signup`; | |
console.log(url); | |
try { | |
await axios.post( | |
url!, | |
{ | |
email, | |
nickname, | |
password, | |
profileUrl, | |
}, | |
{ | |
headers: { | |
"Content-Type": "application/json" | |
} | |
} | |
); | |
let { id: uid } = await signUp({ email, nickname, password, profileUrl }); | |
debugPrint('uid:', uid); | |
router.push('/'); | |
} catch(e) { | |
if (axios.isAxiosError(e)) { | |
if (e.response?.status === 400) { | |
alert('bad request'); | |
} else { | |
alert('unknown error'); | |
} | |
} catch (e) { | |
if (e instanceof BadRequestException) { | |
alert('bad request'); | |
} else { | |
console.error('unknown error >', e); | |
} | |
const handleSignupClick = async () => { | |
if (password.length < 8) { | |
alert('๋น๋ฐ๋ฒํธ๋ 8์ ์ด์์ด์ด์ผ ํฉ๋๋ค.'); | |
return; | |
} | |
try { | |
let { id: uid } = await signUp({ email, nickname, password, profileUrl }); | |
debugPrint('uid:', uid); | |
alert('ํ์๊ฐ์ ์ด ์๋ฃ๋์์ต๋๋ค. ๋ก๊ทธ์ธ ํ์ด์ง๋ก ์ด๋ํฉ๋๋ค.'); | |
router.push('/'); | |
} catch (e) { | |
if (e instanceof BadRequestException) { | |
alert('์ ๋ ฅํ์ ์ ๋ณด๋ฅผ ๋ค์ ํ์ธํด์ฃผ์ธ์. ์ด๋ฉ์ผ ํ์์ด ์ฌ๋ฐ๋ฅธ์ง ํ์ธํด์ฃผ์ธ์.'); | |
} else { | |
console.error('unknown error >', e); | |
alert('ํ์๊ฐ์ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. ์ ์ ํ ๋ค์ ์๋ํด์ฃผ์ธ์.'); | |
} | |
} | |
}; |
๐ Issue ๋ฒํธ
๐ ๏ธ PR ์ธ๋ถ ๋ด์ฉ
client-side api ํธ์ถ์ ์ํ wrapper ํจ์ ์ ์ ->
signin
,signup
์ ์ฉSummary by CodeRabbit
New Features
Refactor