-
Notifications
You must be signed in to change notification settings - Fork 22
Express 김수빈 #54
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 김수빈 #54
The head ref may contain hidden characters: "express-\uAE40\uC218\uBE48"
Conversation
basilry
left a comment
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.
전체적으로 잘 하셨습니다.
백엔드가 상대적으로 프론트보다 분량이 적긴 하죠^^;
고생하셨습니다.
| res.json(articles); | ||
| }; | ||
|
|
||
| // export const createComment = async (req: Request, res: Response) => { |
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.
이건 개발하다가 잠시 멈추신것이겠죠?
| throw new HttpError(400, '리프레시 토큰이 필요합니다'); | ||
| } | ||
|
|
||
| // const result = await authService.refreshAccessToken(refreshToken); |
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.
보통 pr이나 코드리뷰 전에는 이런 주석처리된 소스들은 설명을 달거나 삭제합니다.
|
|
||
| const comment = await commentService.createArticleComment( | ||
| userId, | ||
| userId!, |
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.
이게 지속적으로 반복되는데, 이건 컴파일러에게 그냥 속이는게 아닌가요?
만약에 실제로 userId가 해당 서비스 함수에서 원하는 값이 안들어오면 어떻게 하죠?
차라리 아래처럼 타입가드를 처리하는게 낫지 않을까요?
if (typeof userId !== "number") {
throw new HttpError(401, 'Unauthorized');
}
| const products = await productService.getProducts({ | ||
| page: parseInt(page as string, 10), | ||
| pageSize: parseInt(pageSize as string, 10), | ||
| orderBy: orderBy as string | undefined, |
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.
왜 as를 이렇게 많이 쓰셨나요.
강제로 타입캐스팅을 하는 것보다 인터페이스, 타입을 써서 객체에 할당하는게 낫지 않을까요?
아니면 로직을 수정해서 page: typeof page === "string" ? Number(page) : page로 하는게 낫지 않나요?
참고로 parseInt보다 Number가 메모리를 덜 먹고, 더 빠릅니다.
| @@ -10,8 +10,8 @@ router.get('/', errorHandler(articleController.getArticles)); | |||
| router.get('/:articleId', errorHandler(articleController.getArticle)); | |||
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.
보아하니 에러핸들링을 개별 라우터마다 모두 달아두었는데,
이러지 마시고 app.ts에서 맨 마지막 부분쯤에
app.use(globalErrorHandler);
처럼 구성하는게 낫지 않을까요??
| export const updateArticle = async (id: number, data: Pick<Article, 'title' | 'content'>) => { | ||
| const entity = await articleRepository.Update(id, data); | ||
| if (!entity) throw new HttpError(404, '게시글이 존재하지 않습니다'); | ||
| return { |
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.
개발 중인 부분이겠죠?
요구사항
기본
심화
주요 변경사항
스크린샷
멘토에게
-기존에 구현하지 않은 기능도 있고 코드가 지저분해서 추후 리펙토링 예정입니다 ㅠ
-타입지정만으로도 힘들어서 이번에는 리펙토링을 하지 못햇습니다.