UNPKG

1.47 kBTypeScriptView Raw
1import { PipeTransform, Type } from '@nestjs/common';
2/**
3 * Microservice message pattern payload parameter decorator.
4 *
5 * @publicApi
6 */
7export declare function Payload(): ParameterDecorator;
8/**
9 * Microservice message pattern payload parameter decorator.
10 *
11 * Example:
12 * ```typescript
13 * create(@Payload(new ValidationPipe()) createDto: CreateCatDto)
14 * ```
15 * @param pipes one or more pipes - either instances or classes - to apply to
16 * the bound parameter.
17 *
18 * @publicApi
19 */
20export declare function Payload(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
21/**
22 * Microservice message pattern payload parameter decorator. Extracts a property from the
23 * payload object. May also apply pipes to the bound parameter.
24 *
25 * For example, extracting all params:
26 * ```typescript
27 * findMany(@Payload() ids: string[])
28 * ```
29 *
30 * For example, extracting a single param:
31 * ```typescript
32 * create(@Payload('data') createDto: { data: string })
33 * ```
34 *
35 * For example, extracting a single param with pipe:
36 * ```typescript
37 * create(@Payload('data', new ValidationPipe()) createDto: { data: string })
38 * ```
39 * @param propertyKey name of single property to extract from the message payload
40 * @param pipes one or more pipes - either instances or classes - to apply to
41 * the bound parameter.
42 *
43 * @publicApi
44 */
45export declare function Payload(propertyKey?: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;