Nest adapters and boundaries
Framework lane: NestJS 11.x candidate, TypeScript legacy decorators and emitDecoratorMetadata, compatible reflect-metadata and RxJS. Exact supported patch, dependency lock, advisory review and execution are NOT RUN. The framework code is a static candidate; do not install dependencies or expose a server automatically. The local companion uses Node.js 22.16.0 and requires no third-party packages. A decorator such as @Controller attaches framework metadata; a TypeScript annotation describes a compile-time contract. The full TypeScript chapter follows this introduction. Use a reviewed Nest TypeScript project, not node directly on the .ts file.
Framework example — staged
import { Controller, Get, HttpCode } from '@nestjs/common';@Controller('status')export class StatusController { @Get() @HttpCode(200) status() { return { ready: true }; }}Expected behavior (not observed): Partial controller, register in a reviewed Nest module. Both supported adapter lanes should expose GET /status with a JSON ready value and HTTP 200 after actual integration verification.
How it works
Keep service logic independent of Express or Fastify types. Nest can serialize ordinary return values through its platform layer. Using @Res without passthrough generally transfers responsibility for completing the response to the handler. Adapter-specific plugins, middleware and request/reply APIs require separate review. This lesson stages an adapter comparison; exact Fastify adapter package compatibility remains unverified.
Practice the underlying idea without dependencies
function readiness(dependency) {return {ready:dependency.isReady()};}console.log(JSON.stringify(readiness({isReady:()=>true})), JSON.stringify(readiness({isReady:()=>false})));Run node main.mjs in a disposable directory. Expected output:
{"ready":true} {"ready":false}This tests the illustrated JavaScript behavior only, not the framework.
Common mistake
An Express response method is not guaranteed to exist on a Fastify reply. Test the actual adapter; do not conclude that a portable service test proves HTTP equivalence.
Apply it yourself
Design a transport-independent readiness contract and list the HTTP status, header and body tests needed on each adapter.
Further reading
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Nest adapters and boundaries — knowledge check
Apply the lesson’s contracts and identify common boundary mistakes.
Which code is most portable across Nest HTTP adapters?
What is an adapter responsible for?
What does a dependency-free service test prove?