Performance: Request body
MEDIUM IMPACT
How the server processes incoming data affects response time and overall user experience.
import { Controller, Post, Body } from '@nestjs/common'; @Controller('users') export class UserController { @Post() createUser(@Body() data: CreateUserDto) { // process validated data } }
import { Controller, Post, Req } from '@nestjs/common'; @Controller('users') export class UserController { @Post() createUser(@Req() request) { const data = JSON.parse(request.body); // process data } }
| Pattern | CPU Usage | Event Loop Blocking | Error Handling | Verdict |
|---|---|---|---|---|
| Manual JSON.parse in controller | High | Blocks event loop | Poor | [X] Bad |
| NestJS @Body with validation pipes | Low | Non-blocking | Good | [OK] Good |