backend-controller-pattern-nestjs

Consolidates NestJS controllers into a unified pattern library with base controllers and Zod serialization.

1|Updated Jan 2, 2025
One-click install
npx skills add https://github.com/allenlin90/eridu-services --skill backend-controller-pattern-nestjs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-controller-pattern-nestjs
Source: https://github.com/allenlin90/eridu-services/tree/main/.agent/skills/backend-controller-pattern-nestjs
Command: npx skills add https://github.com/allenlin90/eridu-services --skill backend-controller-pattern-nestjs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Consolidates NestJS controller implementations into a unified pattern library to enforce consistency and reuse across the codebase.

Core Features & Use Cases

  • Shared base controllers and a unified approach to request handling, validation, and responses.
  • DTO-to-service payload translation to decouple HTTP transport from business logic.
  • Platform-wide patterns for Admin, Studio, Me, Backdoor, and Integration controllers with standardized routing and authorization.
  • Practical examples and references to real implementations within the monorepo.

Quick Start

Refactor your NestJS controllers to extend the appropriate base controller and apply the provided decorators to align with the standard patterns.

Frequently Asked Questions about backend-controller-pattern-nestjs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce consistent NestJS controller patterns across different API modules?

To enforce consistent NestJS controller patterns, consolidate implementations into a unified pattern library using shared base controllers. This standardizes request handling, validation, and responses across admin, studio, and integration modules.

What's the best way to decouple HTTP transport from business logic in NestJS controllers?

The best way to decouple HTTP transport from business logic in NestJS controllers is applying DTO-to-service payload translation. This pattern separates incoming request data from the internal service execution logic.

How does Zod serialization work with NestJS controller validation?

Zod serialization decorators in NestJS controllers apply schema-based validation to incoming requests. This mechanism standardizes data validation and UID checks before the controller processes the payload.

Do I need base controllers to standardize access control in a NestJS monorepo?

Yes, you need shared base controllers to standardize access control in a NestJS monorepo. Extending base controllers allows specific modules like backdoor and me to inherit standardized authorization and route scoping.

When do I need different NestJS controller patterns for admin versus integration APIs?

You need different NestJS controller patterns for admin versus integration APIs when route scoping and authorization requirements differ. Applying platform-wide patterns ensures each controller type maintains standardized routing and access control.

Why does NestJS controller consistency break down in large monorepos?

NestJS controller consistency breaks down in large monorepos when implementations are scattered without a unified pattern library. Without shared base controllers and DTO-to-service translation, validation and serialization logic becomes duplicated and fragmented.