@Patch()

Maps a controller method to an HTTP PATCH request for the given path.

Since NestJS 10/11 Spec ↗

Syntax

@Patch(path?: string | string[])

Parameters

NameTypeRequiredDescription
path string | string[] No Optional route path appended to the controller prefix.

Returns

MethodDecorator — A decorator applied to the route handler method.

Examples

import { Controller, Patch, Param, Body } from '@nestjs/common';

@Controller('cats')
export class CatsController {
  @Patch(':id')
  update(@Param('id') id: string, @Body() dto: Partial<{ name: string }>) {
    return { id, ...dto };
  }
}

Notes

PATCH applies a partial modification to a resource. Combine with a DTO of optional fields and the ValidationPipe to safely accept subsets of data.