Implement pagination response handling and related enhancements

- Introduced `@Pagination()` decorator to mark list endpoints for pagination.
- Added `TransformInterceptor` to wrap responses in a standardized format `{ data, meta }`.
- Created pagination-related utility functions and constants for managing pagination logic.
- Defined `PaginationQueryDto` for handling pagination query parameters.
- Established `PaginationMetaDto` for OpenAPI documentation of pagination metadata.
- Updated existing controller and service structures to support pagination in responses.
- Added unit tests for pagination utilities and interceptor to ensure correct functionality.
This commit is contained in:
shancheas
2026-08-21 15:56:54 +07:00
parent d01fd6e2ef
commit 0550cbe764
28 changed files with 1177 additions and 19 deletions
+23
View File
@@ -32,6 +32,29 @@ export class AuthController {
- Public (`@Public()`) routes must omit bearer auth
- Document expected errors (`@ApiBadRequestResponse`, `@ApiUnauthorizedResponse`, etc.) when meaningful
### Paginated list endpoints
- Mark with `@Pagination()`; document the **public** envelope `{ data, meta }`, not the handlers `{ data, total }`
- Use a response DTO class for list items plus `PaginationMetaDto` from `src/common/http/response/`
- Detail / create / update / delete stay typed to the resource DTO (unwrapped)
```typescript
@Get()
@Pagination()
@ApiOperation({ summary: 'List shipments' })
@ApiOkResponse({
schema: {
properties: {
data: { type: 'array', items: { $ref: '#/components/schemas/ShipmentDto' } },
meta: { $ref: '#/components/schemas/PaginationMetaDto' },
},
},
})
list(@Query() query: ListShipmentsQueryDto): Promise<PaginationResponse<ShipmentDto>> {
return this.service.list(query)
}
```
## DTOs
- Request and response DTOs live under `dto/`