nestjs-controllers-services
БесплатноБез исполняемых скриптовНе проверенSeparate Controllers from Services and build Custom Decorators in NestJS. Use when defining NestJS controllers, services, or custom parameter decorators.
от HoangNguyen0403★ 598 звёзд на GitHubОб этом скилле
NestJS Controllers & Services Standards
Priority: P0 (CRITICAL)
Controllers
- Role: Handler only. Delegate all logic to Services.
- Context:
ExecutionContexthelpers (switchToHttp()) for platform-agnostic code. - Custom Decorators:
- Avoid:
@Request() req->req.user(Not type-safe). - Pattern: Create typed decorators like
@CurrentUser(),@DeviceIp().
import { RequestWithUser } from 'src/common/interfaces/request.interface';
export const CurrentUser = createParamDecorator(
(data: unknown, ctx: ExecutionContext): User => {
const request = ctx.switchToHttp().getRequest<RequestWithUser>();
return request.user;
},
);
DTOs & Validation
- Strictness:
whitelist: true: Strip properties without decorators.- Critical:
forbidNonWhitelisted: true: Throw error if unknown properties exist. - Transformation:
transform: true: Auto-convert primitives (String '1' -> Number 1) and instantiate DTO classes.- Documentation:
- Swagger Plugin:
@nestjs/swaggerCLI plugin innest-cli.jsonauto-detects DTO properties — no manual@ApiProperty().
Interceptors (Response Mapping)
- Map responses in Interceptors, not Controllers.
map()wraps success responses (e.g.{ data: T }).- See API Standards for
PageDtoandApiResponse. catchError()maps low-level errors (DB constraints) toHttpException(e.g.ConflictException) before global filter.
Services & Business Logic
- Singleton: Default.
- Stateless: No request-specific state in class properties unless
Scope.REQUEST.
Pipes & Validation
- Global: Register
ValidationPipeglobally. - Route Params: Fail fast. Always use
ParseIntPipe,ParseUUIDPipeon all ID parameters.
@Get(':id')
findOne(@Param('id', ParseIntPipe) id: number) { ... }
Lifecycle Events
- Init: Use
OnModuleInitfor connection setup. - Destroy: Use
OnApplicationShutdownfor cleanup. (RequiresenableShutdownHooks()).
Anti-Patterns
- No business logic in controllers: Delegate everything to Services; controllers only parse and respond.
- No req.user access: Create typed
@CurrentUser()decorator instead of accessing rawreq. - No REQUEST scope by default: Use SINGLETON; it makes entire injection chain request-scoped.
References
Установить nestjs-controllers-services в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл nestjs-controllers-services?
Separate Controllers from Services and build Custom Decorators in NestJS. Use when defining NestJS controllers, services, or custom parameter decorators.
Как установить скилл nestjs-controllers-services?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл nestjs-controllers-services запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic