-
Notifications
You must be signed in to change notification settings - Fork 14
[박수환] sprint11 #35
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
base: express-박수환
Are you sure you want to change the base?
[박수환] sprint11 #35
The head ref may contain hidden characters: "express-\uBC15\uC218\uD658"
Conversation
kimjong95
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.
전체적으로 도메인모델에 대한 정의와 Requset, Response에 대한 타입정의가 이루어지지 않은것 같아요.
타입스크립트를 사용하는 이유는 프로젝트의 안정성을 높히는것 뿐만아니라 코드자체로도 어느정도의 문서화의 역할을 해주기 때문입니다. 잘 정의되어있는 타입들은 개발의 유지보수성도 향상시켜줍니다.
백엔드에서는 이러한 타입시스템을통해서 런타임에 발생할 수 있는 에러를 컴파일타임에 인지하고 해결할수 있게 도와줍니다. 다양한 유틸타입들도 활용하면 좋겠지만 현재는 말씀드린것처럼 모델, request, respnose들의 타입들을 지정해주시고, 공통으로 사용되는 타입들이있다면 묶어서 관리해보면 좋을 것 같습니다.
| "skipLibCheck": true, | ||
| "strictNullChecks": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "noImplicitAny": false, |
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.
any타입에대한 경고를 띄울수있게 해당 옵션은 true로 두면 좋을것 같습니다!
| }); | ||
| } | ||
|
|
||
| async createProduct(userId: string, data: any) { |
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.
data의 타입을 dto형태로 정의해서 사용해주세요!
또한 이렇게 dto타입으로 정했다면 class-validator 와같은 라이브러리로 validation처리도 추가할수 있습니다.
export �class CreateProductDto {
name: string;
description: string;
price: number;
like: number;
imageUrl: string;
userId: string
tags: string[];
}| @Query('search') search?: string, | ||
| @Query('pageSize') pageSize: string = '6', | ||
| ) { | ||
| return this.articleService.getAllArticles(sort, search, Number(pageSize)); |
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.
pageSize를 string으로 받고, number로 캐스팅 하는 이유가 있을까요?
요구사항
기본
백엔드
멘토에게