diff --git a/packages/common/decorators/http/route-params.decorator.ts b/packages/common/decorators/http/route-params.decorator.ts index b14e63cee9d..4c11fc5ed25 100644 --- a/packages/common/decorators/http/route-params.decorator.ts +++ b/packages/common/decorators/http/route-params.decorator.ts @@ -524,6 +524,32 @@ export function Body( */ export function RawBody(): ParameterDecorator; +/** + * Route handler parameter decorator. Extracts the `rawBody` Buffer + * property from the `req` object and populates the decorated parameter with that value. + * Also applies pipes to the bound rawBody parameter. + * + * For example: + * ```typescript + * async create(@RawBody(new ValidationPipe()) rawBody: Buffer) + * ``` + * + * @param pipes one or more pipes - either instances or classes - to apply to + * the bound body parameter. + * + * @see [Request object](https://docs.nestjs.com/controllers#request-object) + * @see [Raw body](https://docs.nestjs.com/faq/raw-body) + * @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes) + * + * @publicApi + */ +export function RawBody( + ...pipes: ( + | Type> + | PipeTransform + )[] +): ParameterDecorator; + /** * Route handler parameter decorator. Extracts the `rawBody` Buffer * property from the `req` object and populates the decorated parameter with that value.