Skip to content
Back to skills

Nestjs Services

ASecurity

Build NestJS modules safely: DI scopes, DTO validation pipes, exception filters, guards and lifecycle hooks

  • 5 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 30, 2026
developmenttestingdatabasesecurity

Security analysis

A100/100

Scanned November 30, 2026

npx -y skills add AdityaaaTiwari/ANVIL --skill nestjs-services --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Nestjs Services?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Nestjs Services
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/adityaaatiwari-nestjs-services-anvil/badge)](https://www.skillsdirectory.com/skills/adityaaatiwari-nestjs-services-anvil)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: nestjs-services
description: "Build NestJS modules safely: DI scopes, DTO validation pipes, exception filters, guards and lifecycle hooks"
---

<!-- Generated by `anvil plugin build` from catalog/. Edit the catalog, not this file. -->

# NestJS services

Use when authoring NestJS controllers, providers, guards, interceptors, or module boundaries.

## Modules and DI
- Keep services request-stateless (`Scope.DEFAULT` singleton). Request-scoped providers (`Scope.REQUEST`) bubble up the entire dependency tree and allocate per request.
- Export only public module facades; use `forwardRef` only as a last resort when decoupling circular dependencies properly is blocked.
- Register `enableShutdownHooks()` so `onModuleDestroy` and `onApplicationShutdown` drain database pools and queues gracefully.

## Validation and pipeline order
- Enable global `ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true })` so unexpected fields never slip into handlers.
- Know the Nest execution sequence: Middleware → Guards → Interceptors (before) → Pipes → Controller → Interceptors (after) → Exception Filters.
- Never catch and swallow database or transport errors silently inside services; map domain errors cleanly to typed HTTP exceptions.

## Security and serialization
Use `ClassSerializerInterceptor` with `@Exclude()` on password/token properties or map explicit response DTOs instead of returning ORM entities directly.

## Verify
Unit tests overriding providers cleanly with `Test.createTestingModule`, plus e2e `supertest` specs exercising guards, whitelist validation rejection, and shutdown cleanup.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.