Skip to content

Commit fd30d7f

Browse files
authored
[#136] πŸ› λΉŒλ“œ μ—λŸ¬ ν•΄κ²° (#137)
* [#99] ✨ add Pagination component * [#99] ✨ add usePagination hook * [#99] πŸ’„ update chevron-right svg with currentColor attribute * [#99] ♻️ refactor button from using label and icons props to children props * [#99] ♻️ reflect changes in Clickable on module content component * [#99] βœ… add Pagination stories * [#99] ✨ add extended twMerge due to the issue with merging custom classes * [#99] ♻️ apply extended twMerge in clickable to test if it works * [#99] ♻️ separate resuable interface (UsePagination) * [#99] ♻️ replace clsx with twMergeEx in Pagination component * [#99] ♻️ add conditional className handling function in Pagination component' * [#99] 🚚 rename UsePaginationReturn into PaginationState * [#134] 🚚 rename api related type locations to types/api/... * [#134] πŸ”§ update generate:types scripts with type saving path * [#134] 🚚 reflect location change of type files on import lines * [#136] πŸ› add return type to functions * [#136] πŸ› fix any type usages by exploiting httperror interface from ky * [#136] πŸ—‘οΈ remove unused lines
1 parent d8b536a commit fd30d7f

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

β€Žsrc/app/(pages)/protected/page.tsxβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default function protectedPage() {
1+
export default function protectedPage(): JSX.Element {
22
return (
33
<>
44
<div>μΈμ¦λ˜μ–΄μ•Όλ§Œ μ ‘κ·Ό κ°€λŠ₯ν•œ νŽ˜μ΄μ§€</div>

β€Žsrc/app/(pages)/sign-up/page.tsxβ€Ž

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
'use client'
22

3-
import { useRouter } from 'next/navigation'
4-
3+
// import { useRouter } from 'next/navigation'
54
import { SubmitHandler, useForm } from 'react-hook-form'
65

76
import { SignUpRequest } from '@/types/api/auth.types'
87
import { useSignUpMutation } from 'queries/useSignUp'
98

109
export default function SignUpPage(): JSX.Element {
11-
const router = useRouter()
10+
// const router = useRouter()
1211
const {
1312
register,
1413
handleSubmit,
15-
formState: { errors },
14+
// formState: { errors },
1615
} = useForm<SignUpRequest>()
1716
const mutation = useSignUpMutation()
1817

β€Žsrc/app/api/auth/refresh/route.tsβ€Ž

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { NextResponse } from 'next/server'
22

3-
import { backendApi } from '@/services/api'
3+
import { HTTPError } from 'ky'
44

5-
const BACKEND_BASE_URL = process.env.NEXT_PUBLIC_BACKEND_BASE_URL
5+
import { backendApi } from '@/services/api'
66

77
export const POST = async (req: Request): Promise<NextResponse> => {
88
const { refreshToken } = await req.json()
@@ -12,10 +12,9 @@ export const POST = async (req: Request): Promise<NextResponse> => {
1212
.post('refresh', { json: { refreshToken } })
1313
.json<{ accessToken: string }>()
1414
return NextResponse.json({ success: true, accessToken })
15-
} catch (error: any) {
15+
} catch (error: unknown) {
1616
console.error('토큰 κ°±μ‹  μ—λŸ¬:', error)
17-
18-
if (error.response) {
17+
if (error instanceof HTTPError) {
1918
const errorData = await error.response.json()
2019
return NextResponse.json(
2120
{
@@ -25,7 +24,6 @@ export const POST = async (req: Request): Promise<NextResponse> => {
2524
{ status: error.response.status }
2625
)
2726
}
28-
2927
return NextResponse.json(
3028
{ success: false, message: 'Internal server error' },
3129
{ status: 500 }

β€Žsrc/app/api/auth/sign-in/route.tsβ€Ž

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import { NextResponse } from 'next/server'
22

3-
import { SignInRequest, SignInResponseResult } from '@/types/api/auth.types'
3+
import { SignInRequest, SignInResponse } from '@/types/api/auth.types'
4+
import { HTTPError } from 'ky'
45

56
import { backendApi } from '@/services/api'
67

78
export const POST = async (req: Request): Promise<NextResponse> => {
8-
const { email, password } = await req.json()
9+
const { email, password }: SignInRequest = await req.json()
910

1011
try {
1112
const { accessToken, refreshToken } = await backendApi
1213
.post('v1/auth/sign-in', {
1314
json: { email, password },
1415
})
15-
.json<SignInResponseResult>()
16+
.json<SignInResponse>()
1617

1718
const res = NextResponse.json({ success: true })
1819

@@ -33,10 +34,10 @@ export const POST = async (req: Request): Promise<NextResponse> => {
3334
})
3435

3536
return res
36-
} catch (error: any) {
37+
} catch (error: unknown) {
3738
console.error('Login failed:', error)
3839

39-
if (error.response) {
40+
if (error instanceof HTTPError) {
4041
const errorData = await error.response.json()
4142
return NextResponse.json(
4243
{ error: errorData.message || 'Login failed' },

β€Žsrc/middleware.tsβ€Ž

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ export const config = {
88
// 인증이 ν•„μš”ν•œ μ‚¬μ΄νŠΈ
99
}
1010

11-
export async function middleware(req: NextRequest) {
11+
export async function middleware(
12+
req: NextRequest
13+
): Promise<NextResponse<unknown>> {
1214
console.log('Middleware is running')
1315
console.log('Requested URL:', req.nextUrl.pathname)
1416
console.log('Headers:', req.headers)
@@ -44,7 +46,7 @@ export async function middleware(req: NextRequest) {
4446
})
4547

4648
return res
47-
} catch (error: any) {
49+
} catch (error: unknown) {
4850
console.error('μ—‘μ„ΈμŠ€ 토큰 κ°±μ‹  μ‹€νŒ¨', error)
4951
return NextResponse.redirect(new URL('/sign-in', req.url))
5052
}

0 commit comments

Comments
Β (0)