nestjs

Implements NestJS REST APIs with layered modules, DTO validation, Prisma persistence, and RFC 9457 errors.

Updated Jul 13, 2026
One-click install
npx skills add https://github.com/urban6/my-harness --skill nestjs-urban6
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: nestjs
Source: https://github.com/urban6/my-harness/tree/main/skills/nestjs
Command: npx skills add https://github.com/urban6/my-harness --skill nestjs-urban6

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing NestJS backend code without established conventions leads to inconsistent layering, leaked entity models, ad-hoc error formats, and security oversights like plaintext password storage. This Skill provides opinionated, idiomatic recipes for building REST APIs, services, and persistence in NestJS projects so the generated code follows consistent patterns. ## Core Features & Use Cases - Layered Architecture Recipes: Enforces module encapsulation with controller → service → Prisma unidirectional dependencies, constructor-based DI, and DTO boundary separation. - Validation & Error Handling: Covers class-validator DTOs with a global ValidationPipe and a global exception filter producing RFC 9457 application/problem+json responses. - Persistence & Security Basics: Provides Prisma schema, migration, transaction, and pagination patterns plus bcrypt/argon2 password hashing, secret externalization via ConfigModule, and Jest testing conventions. - Use Case: When asked to build a signup API in a NestJS project, the Skill produces a feature module with a thin controller, validated DTOs, a service that hashes passwords before storage, Prisma persistence, and consistent error responses. ## Quick Start Use the nestjs skill to implement a new REST endpoint with its module, controller, service, DTOs, and Prisma persistence in this project.

Frequently Asked Questions about nestjs

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

FAQPage Schema
How do I structure a NestJS REST API with modules, controllers, and services?▼

Encapsulate each feature in its own module with a thin controller handling routing and validation, and an @Injectable service containing business logic. Dependencies flow unidirectionally from controller to service to Prisma, using constructor injection throughout.

How to validate request bodies in NestJS with class-validator?▼

Define DTO classes with class-validator decorators like @IsString and @IsInt, then register a global ValidationPipe with whitelist and transform enabled in main.ts. This strips unknown fields, converts types, and returns 400 errors automatically.

Does NestJS support RFC 9457 problem+json error responses?▼

Yes, by implementing a global exception filter that catches HttpException instances and maps them to application/problem+json bodies with type, title, status, detail, and instance fields. Validation failures can include field-level errors in an extensions array.

How do I hash passwords in NestJS before storing them?▼

Wrap bcrypt or @node-rs/argon2 in an injectable PasswordHasher provider and call its hash method in the service before persisting. Never store plaintext passwords, and exclude hash fields from response DTOs and Prisma select queries.

Prisma vs TypeORM in NestJS projects, which does this cover?▼

The recipes center on Prisma with PrismaService, schema.prisma, migrations, and $transaction patterns. For TypeORM or Mikro-ORM projects, the same principles of persistence boundaries and repository abstraction apply using that tool's idioms.

Why does my NestJS e2e test fail against the database?▼

Mocked Prisma clients cannot verify real queries or constraints. Use a separate test database via a .env.test DATABASE_URL, or spin up an isolated Postgres with Testcontainers and apply migrations before running supertest e2e tests.