A progressive Node.js framework for building efficient and scalable server-side applications.
Template for any service, using NestJS (Express wrapper framework)
$ npm install
See the development.env
file
This template uses class-validator
you can read more about it here https://docs.nestjs.com/techniques/validation
Data Transfer Object (DTO) is an object that represents a Request data or a Response data. We have request DTO and response DTO. Request DTO is validated with class-validator, response DTO is just the interface of the data you return to the client, it is not validated, but it can be.
When creating any POST/PATCH request that has data in any controller, make sure to wrap it with DTO interface, NestJS will automatically validate it. exmaple:
@Body() body: MyExampleDto
See the example controller in Backend module.
Controller uses providers to aggregate business logic from different services, helpers, etc. A service aggregates repository data responses, other business logic and returns the data to the provider.
The provider must transform the data accordingly to the expected interface by the controller.
A repository gathers the data from the databases, this can be mongo, sql, elastic, etc..
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov