UNPKG

1.47 kBTypeScriptView Raw
1import { PipeTransform, Type } from '@nestjs/common';
2/**
3 * WebSockets message body parameter decorator.
4 *
5 * @publicApi
6 */
7export declare function MessageBody(): ParameterDecorator;
8/**
9 * WebSockets message body parameter decorator.
10 *
11 * Example:
12 * ```typescript
13 * create(@MessageBody(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 MessageBody(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
21/**
22 * WebSockets message body parameter decorator. Extracts a property from the
23 * message payload object. May also apply pipes to the bound parameter.
24 *
25 * For example, extracting all params:
26 * ```typescript
27 * findMany(@MessageBody() ids: string[])
28 * ```
29 *
30 * For example, extracting a single param:
31 * ```typescript
32 * create(@MessageBody('data') createDto: { data: string })
33 * ```
34 *
35 * For example, extracting a single param with pipe:
36 * ```typescript
37 * create(@MessageBody('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 MessageBody(propertyKey: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;