[하동우]sprint5#97
Hidden character warning
Conversation
ac9831
left a comment
There was a problem hiding this comment.
- .gitignore를 통해 dist 폴더는 제외해 주세요. 왜 필요가 없는지는 dist 폴더의 역할을 한번 찾아보시는 걸 추천드려요.
| ...(title !== undefined && { title }), | ||
| ...(content !== undefined && { content }), | ||
| ...(image !== undefined && { image }), | ||
| }, }); |
There was a problem hiding this comment.
title, content, image 변수가 보이지 않아요
| where: { id }, | ||
| data: { content }, | ||
| }); | ||
|
|
There was a problem hiding this comment.
DB Update 이후 다음 동작이 있어야 할 것 같아요
|
|
||
| try { | ||
| const { userId } = verifyAccessToken(accessToken); | ||
| const user = await prismaClient.user.findUnique({ where: { id: userId } }); |
There was a problem hiding this comment.
여기서 사용하는 userId는 Int로 보이는데요. verifyAccesstoken에서 나오는 userId는 string으로 보이네요
| declare global { | ||
| namespace Express { | ||
| interface Request { | ||
| user?: Omit<PrismaUser, 'password'> | null; |
There was a problem hiding this comment.
PrismaUser를 import 해야 할 것 같네요
|
|
||
| const commentsWithCursor = await prismaClient.comment.findMany({ | ||
| cursor: cursor ? { id: cursor } : undefined, | ||
| take: limit + 1, |
There was a problem hiding this comment.
여기 밑에 추가로 조건 및 패턴을 넣으면 더 정확한 값이 나올 수 있어요. cusor 레코드가 포함될 수 있으니 바꾸는 것을 추천 드립니다.
| const articlesWithLikes = articles.map((article) => ({ | ||
| ...article, | ||
| likes: undefined, | ||
| likeCount: article.likes.length, |
There was a problem hiding this comment.
이 방법보다는 다른 방법으로 각 article별 like를 가져오는 방법이 있어요.
_count를 한번 찾아보세요
| productId Int? | ||
| article Article? @relation(fields: [articleId], references: [id], onDelete: Cascade) | ||
| articleId Int? | ||
| user User @relation(fields: [userId], references: [id]) |
There was a problem hiding this comment.
articleId와 productId가 둘다 null 허용인데요. 둘다 들어올 수도 있습니다.
이걸 막기위해서는 무엇을 해야 할까요?
| import { create } from 'superstruct'; | ||
| import bcrypt from 'bcrypt'; | ||
| import { prismaClient } from '../lib/prismaClient.js'; | ||
| import { generateTokens, verifyRefreshToken } from '../lib/token.js'; |
There was a problem hiding this comment.
.js로 가져오는 코드가 있네요.
ts 방식으로 바꾸는 것을 추천해요
| @@ -0,0 +1,13 @@ | |||
| import { Request, Response, NextFunction } from "express"; | |||
|
|
|||
| type asyncHandler = (req: Request, res: Response)=> Promise<void>; | |||
There was a problem hiding this comment.
Promise로 되어 있는데요.
모든 반환이 void인가요? 아닌것도 있는거 같아서 타입 체크를 하면 틀리게 나올 때가 있을 것 같아요
|
|
||
| export async function createArticle(req: Request, res: Response) { | ||
| if (!req.user) { | ||
| throw new UnauthorizedError('Unauthorized'); |
There was a problem hiding this comment.
에러는 모두 throw → globalErrorHandler에서 처리하는 것을 추천드려요
|
@hadongwoo02 머지 안되는 거 해결 부탁드려요! |
요구사항
기본
심화
주요 변경사항
스크린샷
멘토에게