Back to list
allenlin90

backend-controller-pattern-nestjs

by allenlin90

1🍴 0📅 Jan 24, 2026

SKILL.md


name: backend-controller-pattern-nestjs description: Provides shared NestJS Controller patterns and principles. This skill should be used when implementing controllers in NestJS to ensure consistency and use of shared utilities.

NestJS Controller Patterns (General)

This skill covers the shared principles and common utilities applicable to ALL controller types in erify_api.

Specialized Patterns

For module-specific controller implementation, refer to:

Shared Principles

The following patterns apply across all controller types.

1. Response Serialization

ALL endpoints must use Zod for response serialization to ensure no internal data (like database IDs) leaks.

  • Use @ZodResponse(Schema, Status) for standard responses.
  • Use @ZodPaginatedResponse(Schema) for list endpoints.
@Get(':id')
@ZodResponse(UserDto)
async getUser(...)

2. Validation Pipes

Always use UidValidationPipe for validating uid parameters.

@Param('id', new UidValidationPipe(UserService.UID_PREFIX, 'User'))
id: string

3. DTO Standards

  • Request DTOs: Define validation rules using zod.
  • Response DTOs: Define output shape, excluding sensitive fields.
  • Pagination: Use PaginationQueryDto from @/lib/pagination/pagination.schema.

4. HTTP Status Codes

MethodSuccess CodeDecorator Implementation
GET200 OKDefault / @ZodResponse(S, HttpStatus.OK)
POST201 Created@ZodResponse(S, HttpStatus.CREATED)
PATCH200 OK@ZodResponse(S, HttpStatus.OK)
DELETE204 No Content@ZodResponse(undefined, HttpStatus.NO_CONTENT)

Checklist

  • Choose the correct specialized pattern (Admin, Me, Backdoor, Integration).
  • Use Zod serialization for ALL outputs.
  • Use UidValidationPipe for all UIDs.
  • Document all endpoints with Swagger/OpenAPI decorators (handled via @ZodResponse automatically where possible).

Score

Total Score

50/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon