diff --git a/server/src/cartItems/application/cartItem-list.service.ts b/server/src/cartItems/application/cartItem-list.service.ts index fa1816d..bffe53a 100644 --- a/server/src/cartItems/application/cartItem-list.service.ts +++ b/server/src/cartItems/application/cartItem-list.service.ts @@ -10,6 +10,7 @@ import { findCartItemWithBook } from '../domain/cartItem.repository'; export const getCartItems = async (accessToken: any, selectedId: number[]) => { const { userId } = validateToken(accessToken); + const cartItems = await findCartItemWithBook(userId, selectedId); if (cartItems.length === 0) { throw new HttpException('장바구니가 내 도서 정보가 존재하지 않습니다.', StatusCodes.NOT_FOUND); diff --git a/server/src/cartItems/web/cartItem-list.controller.ts b/server/src/cartItems/web/cartItem-list.controller.ts index 9ddcb61..a69a6db 100644 --- a/server/src/cartItems/web/cartItem-list.controller.ts +++ b/server/src/cartItems/web/cartItem-list.controller.ts @@ -7,6 +7,7 @@ import { getCartItems } from '../application/cartItem-list.service'; const getCartHandler = async ({ body: { selectedId }, headers }: Request, res: Response) => { const accessToken = headers.authorization; + ResponseHandler(() => getCartItems(accessToken, selectedId), StatusCodes.OK, res); }; diff --git a/server/src/users/jwt/jwt.provider.ts b/server/src/users/jwt/jwt.provider.ts index c2fd566..69a4a1b 100644 --- a/server/src/users/jwt/jwt.provider.ts +++ b/server/src/users/jwt/jwt.provider.ts @@ -27,7 +27,13 @@ export const validateToken = (token: string) => { return { userId, }; - } catch (e) { - throw new HttpException('인증 할 수 없는 token 입니다', StatusCodes.UNAUTHORIZED); + } catch (err: any) { + if (err instanceof jwt.TokenExpiredError) { + throw new HttpException('로그인 세션이 만료되었습니다.', StatusCodes.UNAUTHORIZED); + } else if (err instanceof jwt.JsonWebTokenError) { + throw new HttpException('인증 할 수 없는 token 입니다', StatusCodes.BAD_REQUEST); + } + + return err; } };