Nestjs api standards

From HoangNguyen0403/agent-skills-standard · View interactive version

Nestjs api standards is an AI agent skill from the GitHub repository HoangNguyen0403/agent-skills-standard. Create standardized API response envelopes, paginated endpoints, and error interceptors in NestJS. Use when implementing response wrappers, pagination DTOs, or global error formats.

How to use this skill

Skill file

NestJS API Standards & Common Patterns

**Priority: P1 (HIGH)**

Workflow: Standardize API Endpoint

  1. Create Response DTO — Define dedicated DTO for every endpoint return type.
  2. Map entity to DTO — Use plainToInstance(UserResponseDto, user) in service or controller.
  3. Apply TransformInterceptor — Bind globally to wrap all responses in { statusCode, data, meta }.
  4. Add nested validation — Decorate nested DTO properties with @ValidateNested() + @Type().
  5. Document with Swagger — Apply @ApiResponse({ status, type }) with exact types per endpoint.

Response Wrapper Example

See implementation examples

Entity-to-DTO Mapping Example

See implementation examples

Deep Validation (Critical)

Pagination Standards

Custom Error Response

Anti-Patterns

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.