Nest.js
-
[m1 맥북] - nest.js 공부하기 13. 파이프를 이용한 유효성 체크Nest.js 2022. 5. 24. 23:50
필요한 모듈 class-validator , class-transformer npm install class-validator class-transformer --save Documentation 페이지 - https://github.com/typestack/class-validator#manual-validation GitHub - typestack/class-validator: Decorator-based property validation for classes. Decorator-based property validation for classes. Contribute to typestack/class-validator development by creating an account on GitHub...
-
-
[m1 맥북] - nest.js 공부하기 10. ID로 특정 게시물 지우기Nest.js 2022. 5. 23. 22:30
Service단에서 return값이 다른 서비스 함수는 Board모델이 리턴값인데, delete는 굳이 삭제 했기 때문에 리턴값이 없다. 그래서 void 그리고 filter함수를 통해서 board모델에 담겨져 있는 여러가지 게시물들의 id값과 파라미터 id값이 다른거 삭제 할 한가지를 필터 함수로 제거 해주는 로직. Controller단에서 /:id값으로 파라미터값을 받기 때문에 @Param() 모든 파라미터 @Param('id') 특정 파라미터
-
-
[m1 맥북] - nest.js 공부하기 8. 게시물 생성을 위한 DTONest.js 2022. 5. 21. 23:38
게시물 생성을 위한 DTO DTO 실제 생성 해보겠습니다. DTO 파일 작성 DTO 적용하기 //컨트롤 변경전 코드 import { CreateBoardDto } from './dto/create-board.dto'; @Post() createBoard( @Body() createBoardDto: CreateBoardDto ): Board { return this.boardsService.createBoard(createBoardDto); } //서비스 import { CreateBoardDto } from './dto/create-board.dto'; createBoard(createBoardDto: CreateBoardDto) { const { title, description } = createBo..
-
[m1 맥북] - nest.js 공부하기 7. Data Transfer Object(DTO)Nest.js 2022. 5. 21. 23:20
Data transfer Object(DTO) DTO (Data Transfer Object)는 무엇인가요? 계층간 데이터 교환을 위한 객체입니다. DB에서 데이터를 얻어 Service나 Controller 등으로 보낼 때 사용하는 객체 를 말합니다. DTO는 데이터가 네트워크를 통해 전송되는 방법을 정의하는 객체입니다. interface나 class를 이용해서 정의 될 수 있습니다. (하지만 클래스를 이용 하는것을 Nest JS에서는 추천하고 있습니다) Nest JS에서 데이터 처리의 흐름을 보면... Board를 위한 Property들을 여러 곳에서 사용하고 있습니다. ( title, description..) 지금은 간단한 애플리케이션을 만들기 떄문에 몇개의 프로퍼티만 불러 주 고 몇군데에서만 불러..