Nestjs Api Standards
ASecurityUse strict page and response DTOs rather than returning an unbounded array. A typical contract is `PageOptionsDto` (`page`, `take`, `order`) plus `PageDto<T>` containing `data` and pagination metadata. Validate and cap `take`, apply deterministic ordering, and use a cursor strategy when offset pagination becomes expensive. ```ts export class PageOptionsDto { @Type(() => Number) @IsInt() @Min(1) page = 1; @Type(() => Number) @IsInt() @Min(1) @Max(100) take = 20; @IsEnum(Order) order: Order = O...
- 584 stars
- 0 votes
- 0 copies
- 4 views
- Added September 5, 2026
Works with
Security analysis
100/100Pro scans all 11 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill nestjs-api-standards --agent claude-codeAre you the author of Nestjs Api Standards?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-nestjs-api-standards-f279d79e)Use strict page and response DTOs rather than returning an unbounded array. A typical contract is `PageOptionsDto` (`page`, `take`, `order`) plus `PageDto<T>` containing `data` and pagination metadata. Validate and cap `take`, apply deterministic ordering, and use a cursor strategy when offset pagination becomes expensive.
```ts
export class PageOptionsDto {
@Type(() => Number) @IsInt() @Min(1) page = 1;
@Type(() => Number) @IsInt() @Min(1) @Max(100) take = 20;
@IsEnum(Order) order: Order = Order.ASC;
}
export class PageDto<T> {
constructor(public readonly data: T[], public readonly meta: {
page: number; take: number; itemCount: number; pageCount: number;
}) {}
}
```
The service should map entities to response DTOs and return the page metadata. For Swagger generics, register the item and wrapper with `ApiExtraModels` and resolve schemas using `getSchemaPath` in an `ApiPaginatedResponse` decorator.
Files in this skill
- eval-1.baseline.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- eval-3.baseline.md
- eval-3.with-skill.md
- trigger-1.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.