-
Notifications
You must be signed in to change notification settings - Fork 15
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
[강대원] sprint7 #20
base: express-강대원
Are you sure you want to change the base?
The head ref may contain hidden characters: "express-\uAC15\uB300\uC6D0-sprint7"
[강대원] sprint7 #20
Conversation
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.
대체적으로 깔끔하게 작성해주신것 같습니다.
프리즈마를 사용해주고 계신데 관계설정이 잘되어있어서 크게문제되지는 않을것 같습니다.
다만 DB에대한 작업을 할때 key값이 중복, 혹은 존재하지않는 값을 컨트롤 할때의 에러처리가 케이스별로 필요할 수도 있을것 같습니다.
router.patch('/:id/comment/:commentId', service.updateArticleComment); // 자유게시글 댓글 수정 | ||
router.delete('/:id/comment/:commentId', service.deleteArticleComment); // 자유게시글 댓글 삭제 | ||
|
||
export default router; |
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.
게시글과 댓글을 서로다른 컨트롤러로 분리해주셔도 좋을것 같습니다.
const { id } = req.params; // 댓글 ID | ||
const { content } = req.body; | ||
|
||
const comment = await prisma.articleComment.update({ |
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.
수정이나 삭제를할때 id가 유효하지않으면 에러가 발생될 수도 있습니다.
이 케이스를 확인해보시면 좋을것 같아요.
현재는 asyncHandler에 구성된 try/catch로 처리가 되긴 할것 같습니다.
limit = 10, | ||
orderBy = 'recent', | ||
keyword = '', | ||
} = req.query as GetArticleListReqQueryProps; |
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.
query의 타입을 as를 통해 캐스팅해주셨습니다. 이렇게도 사용할 수 있지만 타입단언은 조금 위험할 수도 있습니다.
asyncHandler에 제네릭타입을 통해서 처리할 수도 있을것 같아요.
type GetArticleListReqQueryProps = { | ||
offset?: string; | ||
limit?: string; | ||
orderBy?: string; |
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.
orderBy와 같은값을 string이 아닌 Enum타입등으로 설정하는게 좋을것 같습니다.
marketArticle MarketArticle @relation(fields: [articleId], references: [id], onDelete: Cascade) | ||
articleId String | ||
} | ||
|
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.
모델을 잘 구성해주신것 같아요. 테스트하실때 필요한 시딩이 필요할 수도 있을것 같아요
|
||
const article = await prisma.article.update({ | ||
where: { id }, | ||
data, |
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.
필요한 값만 수정이 되도록 설정해주신것 좋습니다!
요구사항
기본
중고마켓
공통
자유게시판
댓글
주요 변경사항
스크린샷
멘토에게