dabydat/alpha-omega/nestjs-controllers

Claude Code and agent skill by dabydat/alpha-omega

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

NestJS controller patterns for TCP microservices and REST gateways. Covers @MessagePattern for TCP, @Controller for REST, Swagger decorators, DTOs, and ClientProxy patterns. Use when creating controllers, API endpoints, or microservice message handlers.

Install

npx vskill@latest install dabydat/alpha-omega/nestjs-controllers

SKILL.md

NestJS Controllers

Controllers are the entry point to your bounded context. They receive incoming requests and delegate to the application layer (CQRS). Controllers should be thin — they parse input, call handlers, and return output. All business logic lives in handlers, aggregates, or domain services.

Production patterns for: TCP microservices, REST gateways, ClientProxy patterns, DTOs

Agent collaboration: Architect (TCP vs REST decision, BFF pattern), Backend Dev (thin controllers, proper delegation), QA Engineer (integration tests for controllers)


Core Principle: Thin Controllers

See references/thin-controller.md for the BAD (thick) vs GOOD (thin, delegating to CQRS) comparison.


Two Types of Controllers

TCP Controllers (Internal Microservices)

When to use: Communication between internal microservices inside your architecture.

Why TCP over HTTP:

  • Lower latency (no HTTP overhead)
  • Type-safe message patterns (compile-time checking)
  • Natural fit for request-response over message broker
  • Better integration with NestJS microservices package

See references/tcp-controllers.md for full implementation patterns.

REST Controllers (BFF Gateway)

When to use: External clients (web, mobile) accessing your system via REST API.

Why the BFF (Backend-For-Frontend) pattern:

  • External clients cannot use TCP (they speak HTTP)
  • Gateway translates HTTP requests to TCP messages to internal services
  • Gateway handles cross-cutting concerns (auth, rate limiting, response transformation)

See references/rest-controllers.md for full BFF gateway patterns.


Request DTOs

See references/dtos.md for the full CreateEntityRequest example, validation patterns, and Swagger decorators.

Why separate DTOs:

  1. Validation at boundary: class-validator runs before handler executes, failing fast on bad input
  2. Documentation: Swagger decorators generate OpenAPI spec automatically
  3. Isolation: Changes to internal models don't leak to API contract
  4. Clear contract: Frontend devs know exactly what to send

Response DTOs

See references/dtos.md for EntityResponse and EntityListResponse (with pagination meta).

Why separate response DTOs from domain models:

  1. Hide internal structure: Clients don't need to know about your aggregates, VOs, etc.
  2. Versioning: API can evolve independently from domain
  3. Performance: Response DTOs can exclude heavy fields not needed by clients

Controller Constants

See references/dtos.md for the EntityControllerMap example.

Why constants for routes and message patterns:

  1. Single source of truth: One place to change, all references update
  2. Type safety: Compile-time checking if you miss a constant
  3. Discoverability: Constants are colocated, easy to find

Why use `as const`: Makes the object fully readonly at TypeScript level, enabling autocompletion and preventing accidental mutation.


Anti-Patterns to Avoid

See references/anti-patterns.md for the four ❌ examples (business logic, direct repo, missing user context, returning domain models).


Summary: Controller Responsibilities

ResponsibilityWho handles it
Parse HTTP/TCP messageController
Validate inputRequest DTO (class-validator)
Authenticate userGuard (AuthGuard)
Authorize actionGuard or domain
Execute business logicCommand/Query Handler
Enforce invariantsAggregate
Persist dataRepository
Transform outputResponse DTO + Mapper
Handle errorsException Filter

Golden rule: If it's not parsing input or transforming output, it shouldn't be in the controller.


Related Skills

  • nestjs-guards-filters - Guards, filters, and decorators
  • nestjs-cqrs-commands - Command handlers and write operations
  • nestjs-cqrs-queries - Query handlers and read operations

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/dabydat/alpha-omega/nestjs-controllers/badge)](https://verified-skill.com/skills/dabydat/alpha-omega/nestjs-controllers)

Something wrong with this skill or its page? Tell us.