← Back to list

backend-controller-pattern-me
by allenlin90
⭐ 1🍴 0📅 Jan 24, 2026
SKILL.md
name: backend-controller-pattern-me description: Provides NestJS Controller patterns for User-facing (Me) endpoints. This skill should be used when building endpoints for authenticated users to interact with their own resources.
User (Me) Controller Pattern (NestJS)
This skill outlines the patterns for User-facing controllers in erify_api. These endpoints are for authenticated users interacting with their own resources.
Core Principles
- Standard Controller: Standard NestJS controller (no specific base class required, though consistent patterns apply).
- Context: ALWAYS use
@CurrentUser()to scope operations to the authenticated user. - Path Structure: Routes typically start with
me/or implied user context.
Implementation Pattern
import { Controller, Get, Post, Body } from '@nestjs/common';
import { CurrentUser } from '@eridu/auth-sdk/adapters/nestjs/current-user.decorator';
import { AuthenticatedUser } from '@/lib/auth/jwt-auth.guard';
import { ZodResponse } from '@/lib/decorators/zod-response.decorator';
@Controller('me/profile')
export class ProfileController {
constructor(private readonly userService: UserService) {}
@Get()
@ZodResponse(ProfileResponseDto)
async getProfile(@CurrentUser() user: AuthenticatedUser) {
// Validate user context
return this.userService.getUserById(user.id);
}
@Post()
@ZodResponse(ProfileResponseDto)
async updateProfile(
@CurrentUser() user: AuthenticatedUser,
@Body() body: UpdateProfileDto
) {
// ALWAYS use user.id from token, never from body/params for 'me' routes
return this.userService.updateUser(user.id, body);
}
}
Checklist
- Route starts with
me/or is user-scoped. - Uses
@CurrentUser()to get user ID. - NEVER trusts user ID from request body/params for self-operations.
- Uses
@ZodResponseor@ZodPaginatedResponse.
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