Series
Spring Boot to NestJS
41 episodes, in order. The code builds on itself, so following from the start leaves you with a complete system rather than a pile of samples.
-
Spring Boot to NestJS: Everything That Transfers →
One payment system, built twice, on one docker compose file. Most of what a Spring developer knows transfers exactly, some of it transfers with different wiring, and nine things do not transfer at all. Every number here was measured, not estimated.
-
Java to TypeScript: The Setup Nobody Shows You →
Every TypeScript tutorial starts at minute three, on a machine that already has everything installed. This is the part before that, run on a real machine, for Spring Boot developers who have never touched the Node ecosystem.
-
TypeScript for Java Developers: The 20% That Bites →
Your Java instincts read TypeScript correctly about eighty percent of the time. The other twenty percent looks identical and behaves completely differently, and that is where NestJS will bite you.
-
Spring to NestJS Controllers: Two Silent Bugs →
You port a Spring controller to NestJS line by line. It compiles, the application starts, the smoke test passes, and two things are already wrong. Nobody typed either of them.
-
Spring to NestJS Modules: Registered Is Not Visible →
A service that exists, that Nest built, and that the module next door still cannot inject. Nothing is misspelled. The provider is private to its module.
-
Spring to NestJS Async: One Slow Handler, Everyone Waits →
One NestJS request ran for a second and a half, and an unrelated ping took 1.4 seconds. In Spring the same ping took 4 ms. What changed, and the one word that fixes it only when what it awaits yields.
-
Spring to NestJS Configuration: It Started Broken →
A required Spring @Value refuses to start when its property is missing. NestJS starts cleanly and hands you undefined, and the first payment fails. How to buy the startup failure back, and the boolean trap inside the obvious fix.
-
Spring to NestJS Request Validation: Spring Accepted This? →
Spring accepted a payment amount sent as a string and an extra isAdmin field. NestJS, with its validation pipe switched on, rejected both. Validation is really three jobs, and the two stacks put them in different places.
-
Spring to NestJS Exception Filters: 500 or Process Exit? →
An exception thrown inside a request becomes a response on both Spring and NestJS. A rejected promise nobody owns never reaches a filter, and on Node 22 it ends the process. Measured on both stacks, with the filter, the ControllerAdvice beside it, and the two honest fixes.
-
Spring to NestJS Middleware and Interceptors: Filter ≠ Middleware →
A Spring filter catches downstream errors with a try block around chain.doFilter. The same try block around next() in NestJS middleware catches nothing. Measured on both stacks, with the interceptor that does see the error, one map() that reshapes every response, and the Spring hook whose name misleads.
-
Spring to NestJS API Docs with Swagger: 3 Fields → {} →
A typed, validated NestJS request class documents nothing in Swagger by default, while Spring documents the same three fields by itself. Measured on both stacks: why, the hand-written fix that drifts, the CLI plugin that derives it, and the file name boundary it has.
-
Spring to NestJS File Uploads and Downloads: Nest Took 50 MB →
Spring Boot refuses a 2 MB multipart file by default. NestJS on Express with Multer accepts 50 MB and keeps it in memory, where heapUsed barely notices. Measured on both stacks: the defaults, the counter that sees the upload, the two-decision fix, and what four concurrent downloads cost buffered and streamed.
-
Spring to NestJS CORS, Cookies and Sessions: 10,000 Sessions, No Expiry →
A session is the same idea on both stacks: a cookie with an identifier, and state on the server. In NestJS you install that server side yourself, and inherit express-session defaults: a MemoryStore and no expiry. Measured, along with the two browser paths CORS actually takes.
-
Spring to NestJS TypeORM Entities and Repositories: Changed, Not Saved →
Load an entity, change a field, commit, and never call save. Hibernate writes it; TypeORM writes nothing. Measured on both stacks, with save() against update(), a 64 bit value that loses its last digit, and a TypeORM default that changed between major versions.
-
Spring to NestJS TypeORM Relations and Migrations: N+1, or Nothing →
The same loop over 20 orders: Spring counted 60 lines in 21 queries, TypeORM made one query and counted zero. Measured on both stacks, with paging a one-to-many, and generated migrations run on real rows.
-
Spring to NestJS Transactions and Idempotency: Debit, No Credit →
A TypeORM transaction rolled back and the debit survived. Measured on both stacks: what actually joins a transaction, the idempotency race, the unique constraint, and an outbox event for a payment that never existed.
-
Spring to NestJS with MongoDB and Mongoose: Debit Vanished →
Two debits of 30 and 50 from a balance of 100 left 50, on Spring Data MongoDB and on Mongoose. Measured on both stacks: optimistic concurrency, atomic updates, validation by write path, and why $inc needs its rule in the filter.
-
Unit Testing NestJS with Vitest for JUnit Developers: Two Calls, Not One →
A mock shared by two tests carried its calls into the second test in a project nest new created today. Measured against Mockito: mock lifecycle on Vitest 4 and 5, clearMocks against mockReset, strict stubs, and vi.mock hoisting.
-
NestJS Integration Tests with PostgreSQL for Spring Developers: Two Rows, Not One →
Two integration tests against a real Postgres: 1 and 1 under @DataJpaTest, 1 and 2 in NestJS, 3 and 4 on the next run. Where the rollback really comes from, where a test transaction stops, and the reset that works for requests too.
-
Testcontainers for NestJS, for Spring Developers: Fresh Database, Still Two →
A Postgres container per run gave 1 then 2 on every run, on Spring and on NestJS: clean runs, shared tests. Measured: a container per class or file against one for the whole run, and why the order starts to decide.
-
NestJS Guards for Spring Developers: The Route You Forgot →
A refunds route added beside a guarded payments controller answered 401 in Spring Boot and 200 in NestJS. Measured: global guards with a public marker, 401 against 403, and why @PreAuthorize and a Nest role guard protect different things.
-
NestJS Rate Limiting for Spring Developers: The Wrong User Blocked →
Behind a proxy, client two's first request got 429 on Spring Boot and NestJS. Measured: how far to trust X-Forwarded-For, keying by a verified user, in-memory counts against Redis, and a window edge where the two stacks disagreed.
-
Calling APIs from NestJS, for Spring Developers: One Line, Four Traps →
RestClient, @nestjs/axios and the new @nestjs/http-client all waited ten seconds by default. Measured: timeouts and what they do not cancel, the call that never ran, what counts as failure, and a one second timeout that took three.
-
Retries and Circuit Breakers in NestJS, for Spring Developers: One Request, Nine Calls →
One request while the payments API was down became nine calls on Spring Boot and NestJS. Measured: Spring 7 @Retryable and Resilience4j against the new @nestjs/resilience, nested retries, what gets retried, and a breaker that refused fifteen of twenty.
-
Caching in NestJS with Redis, for Spring Developers: Bob Saw Alice →
A cached account endpoint served Alice's balance to Bob on Spring Boot and NestJS. Measured: the key, the lifetime and the fill policy, including when @Cacheable(sync = true) helps on Redis and when it does not.
-
Scheduled Jobs in NestJS, for Spring Developers: Every Job Twice →
Two instances ran every scheduled tick twice on Spring Boot and NestJS. Measured: ShedLock against the new @nestjs/locks, a lock store that did not lock, overlapping runs, one thread and one event loop, and a real crash of the lock holder.
-
Background Jobs in NestJS with BullMQ, for Spring Developers: Crashed, Nothing Sent →
Five receipts handed to @Async or an unawaited promise, then a crash: zero sent. Measured with real processes: what a BullMQ queue keeps, the charge that ran twice, the defaults, and the payment whose receipt never reached the queue.
-
Kafka with NestJS, for Spring Developers: Same Group, Twice →
A Spring and a NestJS consumer both given the group payments handled ten messages twenty times. Measured against a real broker: the group suffix, a group the stacks could not share, a poison message, and the type header that made Spring refuse Nest's JSON.
-
RabbitMQ with NestJS, for Spring Developers: 19,000 Redeliveries →
One payment that always fails: Spring Boot redelivered it over 19,000 times in ten seconds, NestJS delivered it once and lost it. Measured against a real broker: acknowledgement, dead letter queues, and the envelope that made Nest drop Spring's message.
-
Application Events in NestJS, for Spring Developers: Rolled Back, Receipt Sent →
A declined payment rolled back, and the receipt email had already gone, on Spring Boot with a plain @EventListener and on NestJS with @OnEvent. Measured: who waits, who hears a failure, and how to emit only after the commit.
-
WebSockets in NestJS, for Spring Developers: One Slow Client, 48 MB →
A client that stops reading: Spring closed it at 512 KB, NestJS queued about 48 MB for it. Measured on both stacks: Socket.IO against plain WebSocket, fan out across two instances, and the slow-client policy you have to choose.
-
Server-Sent Events in NestJS, for Spring Developers: 33 Updates Sent Again →
A browser on a Spring Boot SSE stream received 33 updates more than once in 70 seconds. Measured on both stacks: how long a stream lives, Last-Event-ID on reconnect, and what a real EventSource does with both.
-
GraphQL in NestJS, for Spring Developers: Production Mode Is Not Enough →
A resolver whose SQL fails: Spring for GraphQL masked it, NestJS with Apollo sent the client the raw Postgres error and a stack trace, and production mode only removed the stack. Measured on both stacks, with the fix.
-
gRPC in NestJS, for Spring Developers: 1999 Plus 1 Is "19991" →
One proto served by Spring Boot and NestJS. An int64 amount plus one: 2000 on Spring, "19991" on Nest with the default loader. Measured on both: the int64 mapping, a throwing handler, and why a missed deadline did not stop the charge.
-
RxJS for Spring Developers: The Customer Left, the Card Was Charged →
Reactor and RxJS share operators, not runtime contracts. Measured on Spring WebFlux and NestJS: what a handler returning a stream sends, the default concurrency of flatMap and mergeMap, and what happens to the work when the client disconnects.
-
Docker for Spring and NestJS: 385 MB to Change One Line →
Our own NestJS Dockerfile handed the builder 385 MB of context and put macOS packages in a Linux build. Measured on both stacks: .dockerignore, multi-stage builds, what one changed line rebuilds, and the root user both images started with.
-
Logging in NestJS, for Spring Developers: Four Lines, Two Ids →
One request logs from four places. On Spring Boot with ECS JSON, two lines carried the request id; on NestJS with its built in logger, none. Measured on both: JSON logs, the MDC and threads, and AsyncLocalStorage through nestjs-pino.
-
OpenTelemetry for Spring and NestJS: 100 Payments, 11 Traces →
A hundred payments through Spring Boot, each calling a NestJS ledger that traces everything: Jaeger showed eleven ledger traces. Measured on both stacks: sampling defaults, propagation, and the root decision that travels downstream.
-
Graceful Shutdown in NestJS, for Spring Developers: Payment Killed →
A stop signal half a second into a payment: NestJS as created was gone in milliseconds, Spring Boot 4.1 finished the payment and drained. Measured on both: Actuator and Terminus, shutdown hooks, and the readiness flip.
-
Email and Translations in NestJS, for Spring Developers: The German Receipt →
A French customer got a German receipt from Spring Boot. Measured against the new first-party @nestjs/i18n and nodemailer: locale fallback, missing keys, a mail server that never answers, and a send that ended a process.
-
Multi Tenancy and Feature Flags, Spring to NestJS: Tenant A Saw Tenant B →
The last episode of the series. Two requests in flight, and one tenant read the other's id. Measured on both stacks: ThreadLocal and AsyncLocalStorage, the cost of request scope, and a rollout that 791 users saw differently.