import { ApiPropertyOptional } from "@nestjs/swagger"; import { Type } from "class-transformer"; import { IsIn, IsInt, IsOptional, IsString, Min } from "class-validator"; export class PaginationQueryDto { @ApiPropertyOptional({ example: 1, default: 1 }) @IsOptional() @Type(() => Number) @IsInt() @Min(1) page?: number = 1; @ApiPropertyOptional({ example: 20, default: 20 }) @IsOptional() @Type(() => Number) @IsInt() @Min(1) limit?: number = 20; @ApiPropertyOptional({ example: "id", default: "id", description: "Field to order by", }) @IsOptional() @IsString() orderBy?: TOrderBy; @ApiPropertyOptional({ enum: ["ASC", "DESC"], default: "ASC" }) @IsOptional() @IsIn(["ASC", "DESC"]) orderDir?: "ASC" | "DESC" = "ASC"; } export interface PaginatedResult { data: T[]; total: number; page: number; limit: number; }