Skip to content

Spike: NestJS

  • Author: ClĂ©ment
  • Date: 2026-11-26
  • Timebox: 30 minutes
  • Why this timebox: the same duration as the FastAPI, ASP.NET Core and Express spikes, so the results can be compared.
  • Time actually spent: about 15 minutes
  • Setup: Node.js 22, npm, TypeScript 5.9, NestJS 11.2 (@nestjs/platform-express), @nestjs/swagger 11.4
  • Prior experience: TypeScript and React from a TECH3 Next.js project; first time with NestJS.

Where I was when the time ran out

  • Server on port 8080
  • GET /ping answers {"status":"ok"}
  • Port read from the PORT environment variable (default 8080; also tested with PORT=9000)
  • OpenAPI page served (bonus): Swagger UI at /docs, JSON document at /openapi.json
  • OAuth login (bonus): not started

What took the most time

  • The OpenAPI bonus. /ping itself is a few lines, but the response schema only shows up in the document once it is a class with @ApiProperty decorators, and decorators need two tsconfig.json options plus reflect-metadata imported first.

What it would take to go further

  • OAuth login: @nestjs/passport with a GitHub strategy, plus a GitHub OAuth app for the client ID and secret.
  • Hooks: @nestjs/schedule for timed polling, or a BullMQ queue (Redis) through @nestjs/bullmq.
  • Docker: a two-stage image (build with tsc, run node dist/main.js).
  • Use the Nest CLI (nest new) for a real project; this spike was set up by hand to stay small.

Notes

  • NestJS runs on Express by default, so it is the same runtime as the Express spike, with modules, controllers and dependency injection on top.
  • The OpenAPI document is generated from the code: the /ping response is a class with @ApiProperty, so the schema cannot drift from the route.
  • Decorators need experimentalDecorators and emitDecoratorMetadata in tsconfig.json, and reflect-metadata imported first.

Running the spike

cd spikes/nestjs
npm install
npm start
curl http://localhost:8080/ping
# OpenAPI page: http://localhost:8080/docs

# Other port:
PORT=9000 npm start

Impressions

  • Liked: the structure (modules, controllers, dependency injection) is clear and close to the OOP we already know from C++; the OpenAPI document comes from the code, so it cannot drift from the routes.
  • Got in the way: more boilerplate than Express for a single route, and the decorator setup is easy to get wrong without the Nest CLI.
  • For AREA: a good fit for a Node server with a described OpenAPI contract. Official packages exist for OAuth (@nestjs/passport) and jobs (@nestjs/schedule, @nestjs/bullmq), which still need trying.