Skip to content

Commit 59bf615

Browse files
committed
refactor(common): Add type declaration for RawBody decorator with pipes
1 parent 439231e commit 59bf615

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

packages/common/decorators/http/route-params.decorator.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,48 @@ export function Body(
508508
);
509509
}
510510

511+
/**
512+
* Route handler parameter decorator. Extracts the `rawBody` Buffer
513+
* property from the `req` object and populates the decorated parameter with that value.
514+
*
515+
* For example:
516+
* ```typescript
517+
* async create(@RawBody() rawBody: Buffer | undefined)
518+
* ```
519+
*
520+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
521+
* @see [Raw body](https://docs.nestjs.com/faq/raw-body)
522+
*
523+
* @publicApi
524+
*/
525+
export function RawBody(): ParameterDecorator;
526+
527+
/**
528+
* Route handler parameter decorator. Extracts the `rawBody` Buffer
529+
* property from the `req` object and populates the decorated parameter with that value.
530+
* Also applies pipes to the bound rawBody parameter.
531+
*
532+
* For example:
533+
* ```typescript
534+
* async create(@RawBody(new ValidationPipe()) rawBody: Buffer)
535+
* ```
536+
*
537+
* @param pipes one or more pipes - either instances or classes - to apply to
538+
* the bound body parameter.
539+
*
540+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
541+
* @see [Raw body](https://docs.nestjs.com/faq/raw-body)
542+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
543+
*
544+
* @publicApi
545+
*/
546+
export function RawBody(
547+
...pipes: (
548+
| Type<PipeTransform<Buffer | undefined>>
549+
| PipeTransform<Buffer | undefined>
550+
)[]
551+
): ParameterDecorator;
552+
511553
/**
512554
* Route handler parameter decorator. Extracts the `rawBody` Buffer
513555
* property from the `req` object and populates the decorated parameter with that value.

0 commit comments

Comments
 (0)