← スキル一覧に戻る

backend-controller-pattern-nestjs
by allenlin90
⭐ 1🍴 0📅 2026年1月24日
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:
- Admin Controllers: For
admin/*endpoints (System Admins). - User (Me) Controllers: For
me/*endpoints (Authenticated Users). - Backdoor Controllers: For
backdoor/*endpoints (Service-to-Service). - Integration Controllers: For
google-sheets/*, webhooks, etc.
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
PaginationQueryDtofrom@/lib/pagination/pagination.schema.
4. HTTP Status Codes
| Method | Success Code | Decorator Implementation |
|---|---|---|
GET | 200 OK | Default / @ZodResponse(S, HttpStatus.OK) |
POST | 201 Created | @ZodResponse(S, HttpStatus.CREATED) |
PATCH | 200 OK | @ZodResponse(S, HttpStatus.OK) |
DELETE | 204 No Content | @ZodResponse(undefined, HttpStatus.NO_CONTENT) |
Checklist
- Choose the correct specialized pattern (
Admin,Me,Backdoor,Integration). - Use Zod serialization for ALL outputs.
- Use
UidValidationPipefor all UIDs. - Document all endpoints with Swagger/OpenAPI decorators (handled via
@ZodResponseautomatically where possible).
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓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
レビュー
💬
レビュー機能は近日公開予定です