Langsung ke konten
Skillpedia
API & server (backend)12k Β· #11440

nestjs-expert

Fungsinya

Skill ini memandu agent AI untuk membangun aplikasi backend dan API TypeScript dengan framework NestJS. Skill ini untuk pengembang yang menginginkan backend Node.js yang terstruktur dan bergaya perusahaan.

Kapan dipakai

  • βœ“Saat Anda membangun API REST atau layanan GraphQL dengan NestJS.
  • βœ“Saat Anda perlu login JWT atau Passport dengan guard.
  • βœ“Saat Anda memindahkan aplikasi Express ke NestJS.

Link skill

https://github.com/Jeffallan/claude-skills/blob/main/skills/nestjs-expert/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/Jeffallan/claude-skills/blob/main/skills/nestjs-expert/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBuat modul NestJS untuk mengelola produk, dengan DTO yang divalidasi dan rute yang dilindungi JWT.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Agent merencanakan modul dan dependensinya, membuat controller dan service dengan validasi, lalu menambahkan guard untuk autentikasi. Setelah itu agent menjalankan lint dan tes serta memeriksa graf dependensi.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

NestJS Expert

Senior NestJS specialist with deep expertise in enterprise-grade, scalable TypeScript backend applications.

Core Workflow

  1. Analyze requirements β€” Identify modules, endpoints, entities, and relationships
  2. Design structure β€” Plan module organization and inter-module dependencies
  3. Implement β€” Create modules, services, and controllers with proper DI wiring
  4. Secure β€” Add guards, validation pipes, and authentication
  5. Verify β€” Run npm run lint, npm run test, and confirm DI graph with nest info
  6. Test β€” Write unit tests for services and E2E tests for controllers

Reference Guide

Load detailed guidance based on context:

Topic Reference Load When
Controllers references/controllers-routing.md Creating controllers, routing, Swagger docs
Services references/services-di.md Services, dependency injection, providers
DTOs references/dtos-validation.md Validation, class-validator, DTOs
Authentication references/authentication.md JWT, Passport, guards, authorization
Testing references/testing-patterns.md Unit tests, E2E tests, mocking
Express Migration references/migration-from-express.md Migrating from Express.js to NestJS

Code Examples

Controller with DTO Validation and Swagger

// create-user.dto.ts
import { IsEmail, IsString, MinLength } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class CreateUserDto {
  @ApiProperty({ example: 'user@example.com' })
  @IsEmail()
  email: string;

  @ApiProperty({ example: '<password>', minLength: 8 })
  @IsString()
  @MinLength(8)
  password: string;
}

// users.controller.ts
import { Body, Controller, Post, HttpCode, HttpStatus } from '@nestjs/common';
import { ApiCreatedResponse, ApiTags } from '@nestjs/swagger';
import { UsersService } from './users.service';
import { CreateUserDto } from './dto/create-user.dto';

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

  @Post()
  @HttpCode(HttpStatus.CREATED)
  @ApiCreatedResponse({ description: 'User created successfully.' })
  create(@Body() createUserDto: CreateUserDto) {
    return this.usersService.create(createUserDto);
  }
}

Service with Dependency Injection and Error Handling

// users.service.ts
import { Injectable, ConflictException, NotFoundException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { User } from './entities/user.entity';
import { CreateUserDto } from './dto/create-user.dto';

@Injectable()
export class UsersService {
  constructor(
    @InjectRepository(User)
    private readonly usersRepository: Repository<User>,
  ) {}

  async create(createUserDto: CreateUserDto): Promise<User> {
    const existing = await this.usersRepository.findOneBy({ email: createUserDto.email });
    if (existing) {
      throw new ConflictException('Email already registered');
    }
    const user = this.usersRepository.create(createUserDto);
    return this.usersRepository.save(user);
  }

  async findOne(id: number): Promise<User> {
    const user = await this.usersRepository.findOneBy({ id });
    if (!user) {
      throw new NotFoundException(`User #${id} not found`);
    }
    return user;
  }
}

Module Definition

// users.module.ts
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UsersController } from './users.controller';
import { UsersService } from './users.service';
import { User } from './entities/user.entity';

@Module({
  imports: [TypeOrmModule.forFeature([User])],
  controllers: [UsersController],
  providers: [UsersService],
  exports: [UsersService], // export only when other modules need this service
})
export class UsersModule {}

Unit Test for Service

// users.service.spec.ts
import { Test, TestingModule } from '@nestjs/testing';
import { getRepositoryToken } from '@nestjs/typeorm';
import { ConflictException } from '@nestjs/common';
import { UsersService } from './users.service';
import { User } from './entities/user.entity';

const mockRepo = {
  findOneBy: jest.fn(),
  create: jest.fn(),
  save: jest.fn(),
};

describe('UsersService', () => {
  let service: UsersService;

  beforeEach(async () => {
    const module: TestingModule
Pertanyaan umum

Bagaimana skill ini memeriksa input?

Skill ini memakai DTO dengan class-validator dan validation pipe.

Bagaimana skill ini menguji aplikasi NestJS?

Skill ini menulis unit test untuk service dan tes end-to-end untuk controller.

Apakah skill ini bisa membantu saya pindah dari Express?

Ya. Skill ini menyertakan panduan migrasi dari Express.js ke NestJS.

Detail

Deskripsi asli dari pembuat

Creates and configures NestJS modules, controllers, services, DTOs, guards, and interceptors for enterprise-grade TypeScript backend applications. Use when building NestJS REST APIs or GraphQL services, implementing dependency injection, scaffolding modular architecture, adding JWT/Passport authentication, integrating TypeORM or Prisma, or working with .module.ts, .controller.ts, and .service.ts files. Invoke for guards, interceptors, pipes, validation, Swagger documentation, and unit/E2E testing in NestJS projects.

repo: Jeffallan/claude-skills

Popularitas

Bintang GitHub
12k
Peringkat
#11440
Lisensi
MIT
Diperbarui
30/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa