NestJS

Nest controller return value

A Nest HTTP adapter connects the framework to an underlying server implementation. Standard controller return values are more portable than direct access to adapter-native response objects. 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. Static example only; runtime NOT RUN. Source: https://docs.nestjs.com/first-steps.

Formal Syntax & Structure

nodejs syntaxnodejs
@Get() method() { return value; }

Working Example

Example Snippetnodejs
import { Controller, Get, HttpCode } from '@nestjs/common';@Controller('status')export class StatusController {  @Get()  @HttpCode(200)  status() { return { ready: true }; }}
Node.js Reference