nestjs-backend

Generates NestJS modules, controllers, services, and tests following dependency injection patterns.

1|Updated Oct 11, 2025
One-click install
npx skills add https://github.com/codewizwit/human-in-the-loop --skill nestjs-backend-codewizwit
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nestjs-backend
Source: https://github.com/codewizwit/human-in-the-loop/tree/main/lib/skills/nestjs-backend
Command: npx skills add https://github.com/codewizwit/human-in-the-loop --skill nestjs-backend-codewizwit

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building scalable Node.js backends with NestJS requires deep knowledge of its module system, dependency injection container, guards, interceptors, and testing conventions. This Skill provides structured guidance and code templates so you produce idiomatic NestJS code instead of falling back on Express-style anti-patterns. ## Core Features & Use Cases - Module & DI Architecture: Generate feature modules, dynamic modules with forRoot/forRootAsync, custom providers, and resolve circular dependencies with events or forwardRef. - Security & Request Handling: Implement JWT authentication guards, role-based authorization, DTO validation with class-validator, and global exception filters. - Testing Templates: Produce unit tests with mocked providers via TestingModule and E2E tests with supertest. - Use Case: Ask to create a products module with CRUD endpoints, and receive a complete controller, service, validated DTOs, and module wiring following NestJS conventions. ## Quick Start Ask the assistant to create a NestJS feature module for user management with CRUD endpoints, DTO validation, and unit tests.

Frequently Asked Questions about nestjs-backend

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

FAQPage Schema
How do I create a NestJS module with CRUD endpoints?▼

Define a feature module with a controller handling HTTP routes, a service containing business logic, and DTOs validated with class-validator. Wire them together in the @Module decorator's controllers and providers arrays, exporting the service for other modules.

How to implement role-based authorization in NestJS?▼

Create a Roles decorator using SetMetadata, then build a RolesGuard implementing CanActivate that reads required roles via Reflector and checks them against the request user's roles. Apply it with @UseGuards alongside your authentication guard.

How do I resolve circular dependencies between NestJS services?▼

Use forwardRef() in both the @Inject decorators and the module imports to break the cycle. A preferred alternative is event-based decoupling with EventEmitter2, where one service emits events and the other listens with @OnEvent.

How do I write unit tests for a NestJS service?▼

Use Test.createTestingModule to build a testing module, providing the service and mocking its dependencies with useValue objects containing jest.fn() stubs. Retrieve instances with module.get and assert mock calls after invoking service methods.

What is the difference between NestJS provider scopes?▼

DEFAULT scope creates one singleton instance, REQUEST scope creates an instance per incoming request, and TRANSIENT scope creates a new instance per consumer. REQUEST and TRANSIENT scopes add overhead and propagate upward to dependent providers.

When should I not use NestJS patterns from Express?▼

Avoid manual middleware chains, callback-based error handling, and global state for dependencies in NestJS. Use decorators for routing, exception filters for errors, the DI container for dependencies, and DTOs with class-validator for validation instead.