Skip to content

Commit 98ad27b

Browse files
committed
[#136] ๐Ÿ› fix any type usages by exploiting httperror interface from ky
1 parent fabc065 commit 98ad27b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

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

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

3+
import { HTTPError } from 'ky'
4+
35
import { backendApi } from '@/services/api'
46

57
const BACKEND_BASE_URL = process.env.NEXT_PUBLIC_BACKEND_BASE_URL
@@ -12,10 +14,9 @@ export const POST = async (req: Request): Promise<NextResponse> => {
1214
.post('refresh', { json: { refreshToken } })
1315
.json<{ accessToken: string }>()
1416
return NextResponse.json({ success: true, accessToken })
15-
} catch (error: any) {
17+
} catch (error: unknown) {
1618
console.error('ํ† ํฐ ๊ฐฑ์‹  ์—๋Ÿฌ:', error)
17-
18-
if (error.response) {
19+
if (error instanceof HTTPError) {
1920
const errorData = await error.response.json()
2021
return NextResponse.json(
2122
{
@@ -25,7 +26,6 @@ export const POST = async (req: Request): Promise<NextResponse> => {
2526
{ status: error.response.status }
2627
)
2728
}
28-
2929
return NextResponse.json(
3030
{ success: false, message: 'Internal server error' },
3131
{ status: 500 }

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

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

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

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

@@ -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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export async function middleware(
4646
})
4747

4848
return res
49-
} catch (error: any) {
49+
} catch (error: unknown) {
5050
console.error('์—‘์„ธ์Šค ํ† ํฐ ๊ฐฑ์‹  ์‹คํŒจ', error)
5151
return NextResponse.redirect(new URL('/sign-in', req.url))
5252
}

0 commit comments

Comments
ย (0)