Skip to content
Contact

Series · 40 parts

NestJS Production Guide

Build a production NestJS API: modules and DI, validation, guards and interceptors, PostgreSQL and TypeORM, caching, queues, real-time, testing, and deployment.

  1. NestJS Architecture Overview

    This is the start of a new series: the NestJS Production Guide.

    Part 1 of 40 · BackendNestJS Architecture Overview — Aman Kumar Singh
  2. Modules and Dependency Injection

    Last time in the NestJS Architecture Overview, the first entry in the NestJS Production Guide, I laid out the layered shape a Nest app settles into: controllers, providers, modules, and the

    Part 2 of 40 · BackendModules and Dependency Injection — Aman Kumar Singh
  3. Providers and Custom Providers

    In Modules and Dependency Injection we covered how modules group related functionality and how the Nest injector resolves dependencies between them.

    Part 3 of 40 · BackendProviders and Custom Providers — Aman Kumar Singh
  4. Controllers and Routing

    Last time, in Providers and Custom Providers, we looked at how NestJS's dependency injection container decides what gets built and when.

    Part 4 of 40 · BackendControllers and Routing — Aman Kumar Singh
  5. DTOs and Validation Pipes

    In Controllers and Routing I covered how requests get mapped to handlers, but I glossed over one detail: what actually happens to the request body between the HTTP layer and your handler fun

    Part 5 of 40 · BackendDTOs and Validation Pipes — Aman Kumar Singh
  6. Guards and Authorization

    Last time in the NestJS Production Guide, I covered DTOs and Validation Pipes, which handles the question of whether a request is well-formed.

    Part 6 of 40 · BackendGuards and Authorization — Aman Kumar Singh
  7. Interceptors Explained

    Last article in the NestJS Production Guide covered Guards and Authorization, the stage in the request lifecycle that decides whether a request is allowed to proceed at all.

    Part 7 of 40 · BackendInterceptors Explained — Aman Kumar Singh
  8. Custom Pipes and Transformation

    In Interceptors Explained, I covered how to wrap a handler on both sides to time requests, reshape responses, and cache results.

    Part 8 of 40 · BackendCustom Pipes and Transformation — Aman Kumar Singh
  9. Exception Filters and Error Handling

    Last time in the NestJS Production Guide, I covered Custom Pipes and Transformation, which is about shaping and validating input before it reaches a handler.

    Part 9 of 40 · BackendException Filters and Error Handling — Aman Kumar Singh
  10. Middleware in NestJS

    The previous article covered exception filters: the stage at the end of the request pipeline that catches whatever went wrong and shapes it into a consistent error response.

    Part 10 of 40 · BackendMiddleware in NestJS — Aman Kumar Singh
  11. Configuration and Environment

    Last time in Middleware in NestJS, part of the NestJS Production Guide, I covered where cross-cutting request logic belongs in the framework's pipeline.

    Part 11 of 40 · BackendConfiguration and Environment — Aman Kumar Singh
  12. Authentication with Passport and JWT

    The last article in this series covered Configuration and Environment: getting secrets, connection strings, and per-environment values into the app safely before you write a single business

    Part 12 of 40 · BackendAuthentication with Passport and JWT — Aman Kumar Singh
  13. Role and Permission Authorization

    The previous article covered Authentication with Passport and JWT: verifying who a user is and issuing a token that proves it.

    Part 13 of 40 · BackendRole and Permission Authorization — Aman Kumar Singh
  14. Connecting PostgreSQL with TypeORM

    Last time in the NestJS Production Guide, I covered Role and Permission Authorization, which assumed a user record existed somewhere to check roles against.

    Part 14 of 40 · BackendConnecting PostgreSQL with TypeORM — Aman Kumar Singh
  15. Database Migrations in NestJS

    The previous article in this NestJS Production Guide series got PostgreSQL and TypeORM talking to each other: a DataSource, an entity or two, a working connection.

    Part 15 of 40 · BackendDatabase Migrations in NestJS — Aman Kumar Singh
  16. The Repository Pattern and Services

    The previous article covered how to evolve a database schema safely once real data is sitting in it. That article assumed your application code already knows how to talk to the database.

    Part 16 of 40 · BackendThe Repository Pattern and Services — Aman Kumar Singh
  17. Transactions and Data Integrity

    The Repository Pattern and Services covered how to keep query logic out of your services and behind a clean interface.

    Part 17 of 40 · BackendTransactions and Data Integrity — Aman Kumar Singh
  18. Caching with Redis in NestJS

    In the last article, Transactions and Data Integrity, we made sure writes to Postgres either fully commit or fully roll back. That's the correctness half of a production backend.

    Part 18 of 40 · BackendCaching with Redis in NestJS — Aman Kumar Singh
  19. Background Jobs with BullMQ

    In Caching with Redis in NestJS we used Redis to avoid recomputing things. This time we use it to avoid doing things right now.

    Part 19 of 40 · BackendBackground Jobs with BullMQ — Aman Kumar Singh
  20. Scheduling and Cron Tasks

    Last time, we covered Background Jobs with BullMQ: the queue-backed way to move slow or unreliable work off the request thread.

    Part 20 of 40 · BackendScheduling and Cron Tasks — Aman Kumar Singh
  21. WebSockets and Gateways

    Last time, I covered scheduling and cron tasks: work the server initiates on its own timeline, with no client waiting on the other end. This article flips that model around.

    Part 21 of 40 · BackendWebSockets and Gateways — Aman Kumar Singh
  22. Server-Sent Events

    The previous article in this NestJS Production Guide series covered WebSockets and gateways: full duplex channels for cases where the client needs to send messages just as often as it receiv

    Part 22 of 40 · BackendServer-Sent Events — Aman Kumar Singh
  23. Handling File Uploads in NestJS

    In the last article, we wired up Server-Sent Events to push live updates from the server without the overhead of a full WebSocket connection.

    Part 23 of 40 · BackendHandling File Uploads in NestJS — Aman Kumar Singh
  24. Sending Emails from NestJS

    In Handling File Uploads in NestJS we dealt with getting bytes from a user into storage without exposing the app to arbitrary files it didn't ask for.

    Part 24 of 40 · BackendSending Emails from NestJS — Aman Kumar Singh
  25. Rate Limiting and Throttling

    Last time, we wired up transactional email sending: welcome messages, password resets, the notifications a SaaS product can't ship without.

    Part 25 of 40 · BackendRate Limiting and Throttling — Aman Kumar Singh
  26. Logging with a Custom Logger

    In Rate Limiting and Throttling we protected the API from abuse and traffic spikes.

    Part 26 of 40 · BackendLogging with a Custom Logger — Aman Kumar Singh
  27. Health Checks and Readiness Probes

    In Logging with a Custom Logger, we made sure that when something goes wrong in production, you can actually see it happen.

    Part 27 of 40 · BackendHealth Checks and Readiness Probes — Aman Kumar Singh
  28. API Documentation with Swagger

    Last time we wired up Health Checks and Readiness Probes so the platform could tell your orchestrator whether the API was actually fit to receive traffic.

    Part 28 of 40 · BackendAPI Documentation with Swagger — Aman Kumar Singh
  29. API Versioning

    Last time in this series, I covered API Documentation with Swagger, because an API nobody can read is an API nobody can safely change.

    Part 29 of 40 · BackendAPI Versioning — Aman Kumar Singh
  30. Pagination and Filtering

    Last time in this series, I covered API Versioning, because once external clients depend on your API, you need a contract you can evolve without breaking them.

    Part 30 of 40 · BackendPagination and Filtering — Aman Kumar Singh
  31. CQRS in NestJS

    Last time in the NestJS Production Guide, I covered Pagination and Filtering, which is the kind of problem every list endpoint eventually runs into. CQRS sits a level up from that.

    Part 31 of 40 · BackendCQRS in NestJS — Aman Kumar Singh
  32. Event-Driven Architecture

    Last time in the NestJS Production Guide, CQRS in NestJS ended on a specific note: publishing an event after a command commits is what lets you decouple side effects, sending a confirmation

    Part 32 of 40 · BackendEvent-Driven Architecture — Aman Kumar Singh
  33. The Outbox Pattern

    Last time in the NestJS Production Guide, I covered Event-Driven Architecture, and closed on a loose end: publishing an event after a database write isn't atomic unless you make it so.

    Part 33 of 40 · BackendThe Outbox Pattern — Aman Kumar Singh
  34. Microservices with NestJS

    Last time in the NestJS Production Guide, I covered The Outbox Pattern, which solves a specific problem: making sure a database write and the event it triggers commit together instead of dri

    Part 34 of 40 · BackendMicroservices with NestJS — Aman Kumar Singh
  35. gRPC Services in NestJS

    Last time in the NestJS Production Guide, I covered Microservices with NestJS, where the transport layer between services was mostly an afterthought: pick TCP or a message broker, wire up Cl

    Part 35 of 40 · BackendgRPC Services in NestJS — Aman Kumar Singh
  36. Unit Testing Services

    Last time in the NestJS Production Guide, I covered gRPC Services in NestJS, which is mostly about wiring one service to talk to another over a fast, typed transport.

    Part 36 of 40 · BackendUnit Testing Services — Aman Kumar Singh
  37. Integration and E2E Testing

    In Unit Testing Services, we covered testing a service's logic in isolation, mocking every dependency so a single test only ever verifies one thing.

    Part 37 of 40 · BackendIntegration and E2E Testing — Aman Kumar Singh
  38. Security Best Practices

    Last time, we covered Integration and E2E Testing: making sure the modules we'd built actually work together, not just in isolation. Tests catch broken behavior.

    Part 38 of 40 · BackendSecurity Best Practices — Aman Kumar Singh
  39. Deploying NestJS to Production

    In Security Best Practices I covered hardening the application itself: input validation, headers, rate limiting, and the usual OWASP checklist.

    Part 39 of 40 · BackendDeploying NestJS to Production — Aman Kumar Singh
  40. A NestJS Production Checklist

    In Deploying NestJS to Production, we walked through getting a NestJS app onto real infrastructure: containerizing it, wiring up CI/CD, and picking a rollout strategy.

    Part 40 of 40 · BackendA NestJS Production Checklist — Aman Kumar Singh