Express 김세환 sprint7#6
Open
CisThard wants to merge 4 commits intocodeit-sprint-fullstack:express-김세환from
Hidden character warning
The head ref may contain hidden characters: "express-\uae40\uc138\ud658-sprint7"
Open
Conversation
seobew
approved these changes
Dec 18, 2024
seobew
left a comment
There was a problem hiding this comment.
세환님 고생하셨습니다 ㅎㅎ
product, article 관련 코드를 나누시려는것 좋았습니다.
다만 서버가 도는 코드를 main.js 혹은 server.js 로 빼고,
product, article부분들을 import하는 형식이었으면 더 좋았을것 같아요!
추가로 validation부분도 있으면 더 좋을것 같아요!
전반적으로 깔끔하게 짜주셨습니다!
수고하셨습니다~
|
|
||
| app.get('/articles/:id', asyncHandler(async (req, res) => { | ||
| const { id } = req.params; | ||
| const article = await prisma.article.findUnique({ |
There was a problem hiding this comment.
findUniqueOrThrow 를 해주시면 바로 validation 에러를 내뱉어줘서 에러 핸들링이 더 쉽습니다~ 현재는 없을때 서버에러가 날거라서요!
| content, | ||
| }, | ||
| }); | ||
| res.json(article); |
| const article = await prisma.article.delete({ | ||
| where: { id }, | ||
| }); | ||
| res.json(article); |
There was a problem hiding this comment.
delete의 경우 204 상태코드와 함께 보통 빈 응답을 내려줍니다 ㅎㅎ
|
|
||
| const runningPort = process.env.PORT || 3000; | ||
| app.listen(runningPort, () => { | ||
| console.log(`Server is running on http://localhost:${runningPort}`); |
There was a problem hiding this comment.
runningPort로 까지는 안빼도 될것 같아요~ ${process.env.PORT || 3000} 요렇게 해주시면 될것 같습니다!
| // 상품 수정 API | ||
| app.patch('/products/:id', asyncHandler(async (req, res) => { | ||
| const id = req.params.id; | ||
| const product = await Product.findById(id); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요구사항
기본 요구사항
중고마켓
공통
자유게시판
댓글
주요 변경사항
스크린샷
멘토에게