One GraphQL schema, many NestJS services. We take a code-first GraphQL API and split it into Apollo Federation v2 subgraphs — a users service that owns the User entity, an orders service that extends it — composed by a gateway that plans queries across both without the client ever knowing.
Pipes are the front door of a NestJS request — they transform and validate input before it ever reaches a service. This post covers the ValidationPipe and DTOs, the options that actually matter (whitelist, transform), parsing and custom pipes, a Zod alternative, generating Swagger/OpenAPI docs from the same DTOs, and how to make validation failures come back in the same error shape as the rest of your API.
Most NestJS apps throw a mix of HttpException, raw Error, and string messages — so the client gets a different shape every time. This post builds a layered error model instead: a base domain error with stable, namespaced string codes, per-domain exception families with typed constructors, cause-chaining, and a single global filter that renders any of them into one consistent, leak-free response (with an RFC 9457 variant).
Unit tests mock the repository. Integration and e2e tests hit a real database — and that is where you need realistic seed data. The TypeORM ecosystem has no great answer for this, and the libraries that exist break every time TypeORM changes its internals. This post builds a tiny factory library that inverts the dependency: TypeORM becomes a six-line adapter, so upgrading it can never break your seeds.
The constructor is not where initialization belongs. NestJS gives you five lifecycle hooks — OnModuleInit, OnApplicationBootstrap, OnModuleDestroy, BeforeApplicationShutdown, and OnApplicationShutdown — each firing at a precise moment in the application's life. This post shows you what each one is for, the order they run in, and what graceful shutdown actually looks like in production.
Most NestJS services are singletons — and that is fine until you need per-request isolation for tenant context, correlation IDs, or stateful helpers. This post explains all three scopes, scope bubbling, durable providers, and when each one belongs in your application.
The official docs show you the four provider shapes. This post shows you when to reach for each one in production code — typed injection tokens, async factory initialization, environment-aware class swapping, alias providers, and a multi-provider plugin system you can extend without touching existing code.
Most devs spend their careers installing NestJS libraries. Today you learn how they are built. We reverse-engineer the patterns from @nestjs/typeorm and @nestjs/config — forRoot, forRootAsync, forFeature, custom decorators — then apply them to a real context-aware logger you can publish to npm.
Part 2 of mocking external APIs: the same NestJS backend, now pointed at WireMock in Docker. File-based stubs, a stateful scenario that starts returning 429 after three calls, runtime switching through the __admin API, and network-level faults like connection resets and malformed responses.
Three patterns that come up constantly in NestJS applications — all in the same order-processing domain so you see how they compose. Strategy picks the shipping algorithm at runtime, Factory decouples order creation from usage, and Observer decouples "order placed" from "what to do about it".
Your backend depends on a third-party API you cannot control. We build a requester pattern where the provider base URL is a single env var, then point the whole app at a Mockoon mock that simulates happy paths, 500s, 403s, 429 rate limiting, and slow responses — with the GUI and @mockoon/cli.
Most NestJS projects default to interfaces. But abstract classes let you define a contract AND ship shared behavior in one construct. This post covers the template method pattern, hook methods, the override keyword, DTO inheritance, and generic base services — all in a real NestJS notification system.
The TypeORM branch of the CASL conditions post. Same record-level idea, but with TypeORM: configure detectSubjectType once so entities need no subject() wrapper, and translate the ability rules into a TypeORM QueryBuilder since there is no official @casl/typeorm adapter.
The sequel to the CASL authorization post. We go from "editors can update articles" to "editors can update their own articles" using CASL conditions, subject detection, a two-layer guard plus service check, query filtering, and field-level permissions in NestJS.
A practical way to organize authorization in NestJS using @casl/ability: typed actions and subjects, one permission file per subject, an ability factory, and a guard with a CheckAbility decorator that keeps controllers clean.
A practical discussion about where DTOs should live, how services should receive input, when to create interfaces, and how to organize errors, interceptors, filters, and transactions in a NestJS application.
Real-time communication is an intriguing topic, and I wanted to share my thoughts on it. I came across one of my old blog posts about micro frontends, where I developed an interface for a micro frontend chat feature that
NestJS-based payment gateway integration service. It provides a unified interface for processing payments through various payment processors such as Stripe, PayPal, and others. The service handles payment initialization, processing, and refunding, ensuring a seamless payment experience for users.
A practical implementation of multi-tenancy using NestJS and TypeORM, managing multiple databases for customers, with features like database migrations and connection handling. Future improvements could include real-time database verification and a caching layer for better scalability.
Hello, developers! Welcome to the second part of our NestJS + Clean Architecture + DDD series. In this post, we'll delve into abstractions and explore how they can be used to create scalable systems that are agnostic to
Hello, dev! Let's start one more sequence of exciting technical posts related to the NestJS ecosystem, and in this sequence, I am going to review and exercise with you concepts like:
Hello fellow coders! I have a polemic topic to talk about today, it is “using AI to create the unit and e2e tests” and how it can improve the velocity of writing tests!!!
Hello fellow coders! This time we are going to have a different post, I am not going to focus on Nestjs technical details instead, I'm going to explain a bit more different concepts than those that we've already seen on
Hello fellow coders! Today we are going to talk a bit about tests inside NestJS, let’s start looking at and applying one type of test and later we are going to see another, so the first one will be e2e.
Hello fellow coders! In this post we are still going to talk about tests, but, instead of e2e we are going to implement unit tests, I’d say they are kind of siblings, however, each one does different things, and they hav
Hello fellow coders! Today we are going to replace TypeORM with Prisma inside a simple previous project that we built, it’s gonna be simple and quick, so let’s get started!
Hello fellow coders! Let's continue our series of NestJS auth flow implementations, and today we are going to add a database integration to keep users saved basically to work with the auth module.
Hey there, fellow coders! Let's continue our NestJS auth flow, right? Today we are going to create the two main modules auth and user, they will be very simple just to go straight to the point.
Hello fellow coders! Today we are going to talk about something simple that basically everybody and every project does, which is using ENVs inside a project, it can be database credentials, project port, name of queue, o
Software development is a dynamic field, constantly evolving and presenting fresh challenges. It is a journey that demands continuous learning and adaptability. Have you ever wondered what it takes to navigate through th
Hey there, fellow coders! 🚀 Ready to dive into the world of authentication flows? Buckle up because we're about to take a turbo-charged ride with NestJS to implement auth flow faster than you can say "password reset." I
Hi guys! Let’s start another technical post and this time I did something that I really enjoyed, it was an App that uses the famous OpeanIA, and the best part about everything, this app is a Flashcard app, so you can use
Hi dear reader! This is one more project I did to practice a few technologies, so you'll see NestJS, NextJS, SQS, Tests, and MongoDB, all exciting technologies! I'm sure you'll enjoy this post and project as much as I di