ramziddin/ccplugins · Archived

nestjs

Comprehensive NestJS framework skills covering controllers, providers, modules, middleware, guards, interceptors, pipes, validation, authentication, GraphQL, microservices, and more. Use when working with NestJS applications.

First seen Mar 29, 2026

Installation

$ npx skills add ramziddin/ccplugins --skill nestjs

Stronger alternatives

This repository is archived — consider an actively maintained alternative.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from ramziddin/ccplugins · top by installs.

npx skills add ramziddin/ccplugins

Browse all from ramziddin/ccplugins

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Stars 1
License MIT
Default branch main
Open issues 0
Status Archived

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 10,433 B
  • docs SUMMARY.md 239 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 3 installs

SKILL.md

NestJS Framework Skills

This skill collection provides comprehensive guidance for building applications with NestJS, a progressive Node.js framework for building efficient, scalable server-side applications.

Available Skills

Core Concepts

These skills cover the fundamental building blocks of every NestJS application:

  • [basics](skills/basics/SKILL.md) - Project setup, installation, CLI usage, and core architecture concepts
  • [controllers](skills/controllers/SKILL.md) - HTTP request handling, routing, route parameters, query parameters, and request payloads
  • [providers](skills/providers/SKILL.md) - Services, dependency injection, and the IoC container
  • [modules](skills/modules/SKILL.md) - Application organization, feature modules, shared modules, and dynamic modules
  • [middleware](skills/middleware/SKILL.md) - Request/response preprocessing, logging, and authentication middleware
  • [guards](skills/guards/SKILL.md) - Route protection, authorization, and role-based access control
  • [interceptors](skills/interceptors/SKILL.md) - Response transformation, logging, caching, and timeout handling
  • [pipes](skills/pipes/SKILL.md) - Data validation and transformation with class-validator
  • [exception-filters](skills/exception-filters/SKILL.md) - Error handling and custom exception responses
  • [custom-decorators](skills/custom-decorators/SKILL.md) - Creating reusable decorators for parameters, metadata, and composition

Fundamentals

Advanced topics for mastering NestJS architecture:

  • [dependency-injection](skills/dependency-injection/SKILL.md) - Custom providers, factory providers, async providers, and injection scopes
  • [testing](skills/testing/SKILL.md) - Unit testing, integration testing, E2E testing, and mocking strategies
  • [lifecycle](skills/lifecycle/SKILL.md) - Lifecycle hooks for modules, providers, and application bootstrapping

Techniques

Practical techniques for common application requirements:

  • [configuration](skills/configuration/SKILL.md) - Environment variables, configuration validation, and custom config files
  • [validation](skills/validation/SKILL.md) - Request validation with class-validator and ValidationPipe
  • [database](skills/database/SKILL.md) - SQL databases with TypeORM/Prisma and MongoDB with Mongoose
  • [caching](skills/caching/SKILL.md) - In-memory and Redis caching strategies
  • [task-scheduling](skills/task-scheduling/SKILL.md) - Cron jobs, intervals, and dynamic task scheduling
  • [queues](skills/queues/SKILL.md) - Background job processing with Bull and Redis

Security

Security best practices and authentication/authorization:

  • [authentication](skills/authentication/SKILL.md) - JWT authentication, Passport integration, and auth strategies
  • [authorization](skills/authorization/SKILL.md) - Role-based access control (RBAC) and permission-based authorization
  • [security](skills/security/SKILL.md) - CORS, CSRF protection, Helmet, rate limiting, and encryption

Advanced Topics

Advanced features for building complex applications:

  • [graphql](skills/graphql/SKILL.md) - GraphQL integration, resolvers, queries, mutations, and subscriptions
  • [websockets](skills/websockets/SKILL.md) - Real-time communication with WebSocket gateways
  • [microservices](skills/microservices/SKILL.md) - Microservices architecture with various transport layers (TCP, Redis, NATS, Kafka, gRPC)
  • [cli](skills/cli/SKILL.md) - NestJS CLI commands, code generation, and project scaffolding
  • [openapi](skills/openapi/SKILL.md) - API documentation with Swagger/OpenAPI

Quick Reference

Request Processing Pipeline

Incoming Request
    ↓
Middleware ──────────── Global → Module → Route
    ↓
Guards ─────────────── Global → Controller → Route
    ↓
Interceptors (before) ── Global → Controller → Route
    ↓
Pipes ──────────────── Global → Controller → Route → Parameter
    ↓
Route Handler ───────── Controller Method
    ↓
Interceptors (after) ─── Route → Controller → Global
    ↓
Exception Filters ────── Route → Controller → Global
    ↓
Response

Common CLI Commands

# Installation
npm i -g @nestjs/cli
nest new project-name

# Code Generation
nest generate module users
nest generate controller users
nest generate service users
nest generate resource users  # Generates module, controller, service, DTOs

# Running
npm run start:dev    # Development mode with watch
npm run start:debug  # Debug mode
npm run start:prod   # Production mode

# Testing
npm run test         # Unit tests
npm run test:watch   # Unit tests with watch
npm run test:cov     # Coverage
npm run test:e2e     # End-to-end tests

# Building
npm run build        # Production build

Architecture Patterns

Feature Module Pattern

@Module({
  imports: [TypeOrmModule.forFeature([User])],
  controllers: [UsersController],
  providers: [UsersService, UsersRepository],
  exports: [UsersService],
})
export class UsersModule {}

Service Layer Pattern

@Injectable()
export class UsersService {
  constructor(
    private readonly repository: UsersRepository,
    private readonly emailService: EmailService,
  ) {}

  async create(dto: CreateUserDto): Promise<User> {
    const user = await this.repository.create(dto);
    await this.emailService.sendWelcome(user.email);
    return user;
  }
}

Controller Pattern

@Controller('users')
export class UsersController {
  constructor(private readonly service: UsersService) {}

  @Get()
  findAll(@Query() query: QueryDto) {
    return this.service.findAll(query);
  }

  @Post()
  @UseGuards(JwtAuthGuard)
  create(@Body() dto: CreateUserDto) {
    return this.service.create(dto);
  }
}

Dependency Injection Patterns

// Standard injection
constructor(private readonly service: MyService) {}

// Custom token injection
constructor(@Inject('CONFIG') private config: Config) {}

// Optional dependency
constructor(@Optional() private logger?: Logger) {}

// Multiple providers with same token
constructor(@Inject('FEATURES') private features: Feature[]) {}

Validation Pattern

import { IsString, IsInt, Min, Max, IsEmail } from 'class-validator';

export class CreateUserDto {
  @IsString()
  @Length(3, 50)
  name: string;

  @IsEmail()
  email: string;

  @IsInt()
  @Min(0)
  @Max(120)
  age: number;
}

// Use globally
app.useGlobalPipes(new ValidationPipe({
  whitelist: true,
  forbidNonWhitelisted: true,
  transform: true,
}));

Authentication Pattern

// JWT Strategy
@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
  constructor(config: ConfigService) {
    super({
      jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
      secretOrKey: config.get('JWT_SECRET'),
    });
  }

  validate(payload: any) {
    return { userId: payload.sub, username: payload.username };
  }
}

// Protected Route
@Controller('profile')
@UseGuards(JwtAuthGuard)
export class ProfileController {
  @Get()
  getProfile(@Request() req) {
    return req.user;
  }
}

Best Practices

General Architecture

  1. One feature per module - Keep related code together
  2. Thin controllers - Delegate business logic to services
  3. Use DTOs - Define data transfer objects for validation
  4. Dependency injection - Inject all dependencies via constructor
  5. Separation of concerns - Controllers → Services → Repositories

Code Organization

  1. Feature-based structure - Organize by feature, not by layer
  2. Shared modules - Create common modules for reusable functionality
  3. Clear naming - Use descriptive names (UsersService, not Service1)
  4. Consistent patterns - Follow the same patterns throughout

Performance

  1. Use singleton scope - Default scope for most providers
  2. Enable caching - Cache frequently accessed data
  3. Use Fastify - For better performance than Express
  4. Database optimization - Use indexes, eager/lazy loading wisely
  5. Async operations - Use async/await for I/O operations

Security

  1. Validate all input - Use ValidationPipe globally
  2. Sanitize data - Prevent XSS and SQL injection
  3. Use HTTPS - Enable SSL/TLS in production
  4. Rate limiting - Prevent abuse
  5. Security headers - Use Helmet middleware
  6. Authentication - Implement proper auth (JWT, OAuth)
  7. Authorization - Protect routes with guards

Testing

  1. Write unit tests - Test services and business logic
  2. Integration tests - Test module interactions
  3. E2E tests - Test complete user flows
  4. Mock dependencies - Isolate units being tested
  5. Test coverage - Aim for >80% coverage

Error Handling

  1. Use built-in exceptions - BadRequestException, NotFoundException, etc.
  2. Custom exception filters - For consistent error responses
  3. Logging - Log errors with context
  4. Graceful degradation - Handle failures gracefully
  5. Validation errors - Return clear validation messages

Resources

Getting Started

If you're new to NestJS, start with these skills in order:

  1. [basics](skills/basics/SKILL.md) - Set up your first project
  2. [controllers](skills/controllers/SKILL.md) - Create API endpoints
  3. [providers](skills/providers/SKILL.md) - Add business logic
  4. [modules](skills/modules/SKILL.md) - Organize your application
  5. [validation](skills/validation/SKILL.md) - Validate request data
  6. [authentication](skills/authentication/SKILL.md) - Secure your API
  7. [database](skills/database/SKILL.md) - Connect to a database

Then explore the other skills based on your application's needs.