Skip to main content

Installation​

See the installation guide. This example uses the TypeORM adapter, so install it and TypeORM alongside the REST package (plus the TypeORM driver for your database):

Define the DTOs​

The response DTO declares the fields returned by the API and which fields clients may filter on. Separate create and update DTOs keep writable fields explicit.
todo-item.dto.ts
todo-item-input.dto.ts
todo-item-update.dto.ts

Register an endpoint​

Register the persistence module and describe the endpoint in NestjsQueryRestModule.forFeature. basePath is optional; without it, the path is derived by pluralizing the DTO class name (TodoItemDTO becomes /todo-item-dtos).
todo-item.module.ts
This creates the following endpoints:

Enable request transformation and validation​

The generated query and body DTOs use class-transformer and class-validator. Enable Nest’s ValidationPipe so query strings such as limit=10 are converted and validated.
main.ts
Continue with DTOs, controllers, or the query endpoint examples.