This implementation shows how Automapper can be used to convert between Data Transfer Objects (DTO) and other classes. Automapper allows for the code that performs the transformation to be abstracted away from the controllers and services.
Required:
npm install @automapper/{core, classes, nestjs}, class-transformer class-validator
npm install --save-dev @automapper/typesIf you are running this on StackBlitz (https://stackblitz.com/github/Tevpro/nest-automapper-demo) you will need to execute the following commands and access the URL below to test.
nest startNext append /api to the end of the url inside the StackBlitz browser panel to access swagger.
- Blog - Understanding AutoMapper and it's use in a NestJS application
- Website - Tevpro - https://tevpro.com
- Author - Keith Kikta Blog