-
Notifications
You must be signed in to change notification settings - Fork 4
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
Express 김세환 sprint7 #6
base: express-김세환
Are you sure you want to change the base?
The head ref may contain hidden characters: "express-\uAE40\uC138\uD658-sprint7"
Express 김세환 sprint7 #6
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.
세환님 고생하셨습니다 ㅎㅎ
product, article 관련 코드를 나누시려는것 좋았습니다.
다만 서버가 도는 코드를 main.js 혹은 server.js 로 빼고,
product, article부분들을 import하는 형식이었으면 더 좋았을것 같아요!
추가로 validation부분도 있으면 더 좋을것 같아요!
전반적으로 깔끔하게 짜주셨습니다!
수고하셨습니다~
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.
오.. 배포를 docker로 하시는건가요? 더할나위없이 좋습니다!
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findUniqueOrThrow 를 해주시면 바로 validation 에러를 내뱉어줘서 에러 핸들링이 더 쉽습니다~ 현재는 없을때 서버에러가 날거라서요!
content, | ||
}, | ||
}); | ||
res.json(article); |
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.
create의 경우 201 상태코드를 같이 내려주는게 좋을것 같아요
const article = await prisma.article.delete({ | ||
where: { id }, | ||
}); | ||
res.json(article); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
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.
요렇게도 좋은데 Product.update가 더 나을것 같아요
요구사항
기본 요구사항
중고마켓
공통
자유게시판
댓글
주요 변경사항
스크린샷
멘토에게