UNPKG

14 kBTypeScriptView Raw
1import { PipeTransform } from '../../index';
2import { Type } from '../../interfaces';
3/**
4 * The `@Response()`/`@Res` parameter decorator options.
5 */
6export interface ResponseDecoratorOptions {
7 /**
8 * Determines whether the response will be sent manually within the route handler,
9 * with the use of native response handling methods exposed by the platform-specific response object,
10 * or if it should passthrough Nest response processing pipeline.
11 *
12 * @default false
13 */
14 passthrough: boolean;
15}
16export declare type ParamData = object | string | number;
17export interface RouteParamMetadata {
18 index: number;
19 data?: ParamData;
20}
21export declare function assignMetadata<TParamtype = any, TArgs = any>(args: TArgs, paramtype: TParamtype, index: number, data?: ParamData, ...pipes: (Type<PipeTransform> | PipeTransform)[]): TArgs & {
22 [x: string]: {
23 index: number;
24 data: ParamData;
25 pipes: (PipeTransform<any, any> | Type<PipeTransform<any, any>>)[];
26 };
27};
28/**
29 * Route handler parameter decorator. Extracts the `Request`
30 * object from the underlying platform and populates the decorated
31 * parameter with the value of `Request`.
32 *
33 * Example: `logout(@Request() req)`
34 *
35 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
36 *
37 * @publicApi
38 */
39export declare const Request: () => ParameterDecorator;
40/**
41 * Route handler parameter decorator. Extracts the `Response`
42 * object from the underlying platform and populates the decorated
43 * parameter with the value of `Response`.
44 *
45 * Example: `logout(@Response() res)`
46 *
47 * @publicApi
48 */
49export declare const Response: (options?: ResponseDecoratorOptions) => ParameterDecorator;
50/**
51 * Route handler parameter decorator. Extracts reference to the `Next` function
52 * from the underlying platform and populates the decorated
53 * parameter with the value of `Next`.
54 *
55 * @publicApi
56 */
57export declare const Next: () => ParameterDecorator;
58/**
59 * Route handler parameter decorator. Extracts the `Ip` property
60 * from the `req` object and populates the decorated
61 * parameter with the value of `ip`.
62 *
63 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
64 *
65 * @publicApi
66 */
67export declare const Ip: () => ParameterDecorator;
68/**
69 * Route handler parameter decorator. Extracts the `Session` object
70 * from the underlying platform and populates the decorated
71 * parameter with the value of `Session`.
72 *
73 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
74 *
75 * @publicApi
76 */
77export declare const Session: () => ParameterDecorator;
78/**
79 * Route handler parameter decorator. Extracts the `file` object
80 * and populates the decorated parameter with the value of `file`.
81 * Used in conjunction with
82 * [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
83 *
84 * For example:
85 * ```typescript
86 * uploadFile(@UploadedFile() file) {
87 * console.log(file);
88 * }
89 * ```
90 * @see [Request object](https://docs.nestjs.com/techniques/file-upload)
91 *
92 * @publicApi
93 */
94export declare function UploadedFile(): ParameterDecorator;
95/**
96 * Route handler parameter decorator. Extracts the `file` object
97 * and populates the decorated parameter with the value of `file`.
98 * Used in conjunction with
99 * [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
100 *
101 * For example:
102 * ```typescript
103 * uploadFile(@UploadedFile() file) {
104 * console.log(file);
105 * }
106 * ```
107 * @see [Request object](https://docs.nestjs.com/techniques/file-upload)
108 *
109 * @publicApi
110 */
111export declare function UploadedFile(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
112/**
113 * Route handler parameter decorator. Extracts the `file` object
114 * and populates the decorated parameter with the value of `file`.
115 * Used in conjunction with
116 * [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
117 *
118 * For example:
119 * ```typescript
120 * uploadFile(@UploadedFile() file) {
121 * console.log(file);
122 * }
123 * ```
124 * @see [Request object](https://docs.nestjs.com/techniques/file-upload)
125 *
126 * @publicApi
127 */
128export declare function UploadedFile(fileKey?: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
129/**
130 * Route handler parameter decorator. Extracts the `files` object
131 * and populates the decorated parameter with the value of `files`.
132 * Used in conjunction with
133 * [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
134 *
135 * For example:
136 * ```typescript
137 * uploadFile(@UploadedFiles() files) {
138 * console.log(files);
139 * }
140 * ```
141 * @see [Request object](https://docs.nestjs.com/techniques/file-upload)
142 *
143 * @publicApi
144 */
145export declare function UploadedFiles(): ParameterDecorator;
146/**
147 * Route handler parameter decorator. Extracts the `files` object
148 * and populates the decorated parameter with the value of `files`.
149 * Used in conjunction with
150 * [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
151 *
152 * For example:
153 * ```typescript
154 * uploadFile(@UploadedFiles() files) {
155 * console.log(files);
156 * }
157 * ```
158 * @see [Request object](https://docs.nestjs.com/techniques/file-upload)
159 *
160 * @publicApi
161 */
162export declare function UploadedFiles(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
163/**
164 * Route handler parameter decorator. Extracts the `headers`
165 * property from the `req` object and populates the decorated
166 * parameter with the value of `headers`.
167 *
168 * For example: `async update(@Headers('Cache-Control') cacheControl: string)`
169 *
170 * @param property name of single header property to extract.
171 *
172 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
173 *
174 * @publicApi
175 */
176export declare const Headers: (property?: string) => ParameterDecorator;
177/**
178 * Route handler parameter decorator. Extracts the `query`
179 * property from the `req` object and populates the decorated
180 * parameter with the value of `query`. May also apply pipes to the bound
181 * query parameter.
182 *
183 * For example:
184 * ```typescript
185 * async find(@Query('user') user: string)
186 * ```
187 *
188 * @param property name of single property to extract from the `query` object
189 * @param pipes one or more pipes to apply to the bound query parameter
190 *
191 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
192 *
193 * @publicApi
194 */
195export declare function Query(): ParameterDecorator;
196/**
197 * Route handler parameter decorator. Extracts the `query`
198 * property from the `req` object and populates the decorated
199 * parameter with the value of `query`. May also apply pipes to the bound
200 * query parameter.
201 *
202 * For example:
203 * ```typescript
204 * async find(@Query('user') user: string)
205 * ```
206 *
207 * @param property name of single property to extract from the `query` object
208 * @param pipes one or more pipes to apply to the bound query parameter
209 *
210 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
211 *
212 * @publicApi
213 */
214export declare function Query(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
215/**
216 * Route handler parameter decorator. Extracts the `query`
217 * property from the `req` object and populates the decorated
218 * parameter with the value of `query`. May also apply pipes to the bound
219 * query parameter.
220 *
221 * For example:
222 * ```typescript
223 * async find(@Query('user') user: string)
224 * ```
225 *
226 * @param property name of single property to extract from the `query` object
227 * @param pipes one or more pipes to apply to the bound query parameter
228 *
229 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
230 *
231 * @publicApi
232 */
233export declare function Query(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
234/**
235 * Route handler parameter decorator. Extracts the entire `body`
236 * object from the `req` object and populates the decorated
237 * parameter with the value of `body`.
238 *
239 * For example:
240 * ```typescript
241 * async create(@Body() createDto: CreateCatDto)
242 * ```
243 *
244 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
245 *
246 * @publicApi
247 */
248export declare function Body(): ParameterDecorator;
249/**
250 * Route handler parameter decorator. Extracts the entire `body`
251 * object from the `req` object and populates the decorated
252 * parameter with the value of `body`. Also applies the specified
253 * pipes to that parameter.
254 *
255 * For example:
256 * ```typescript
257 * async create(@Body(new ValidationPipe()) createDto: CreateCatDto)
258 * ```
259 *
260 * @param pipes one or more pipes - either instances or classes - to apply to
261 * the bound body parameter.
262 *
263 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
264 * @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
265 *
266 * @publicApi
267 */
268export declare function Body(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
269/**
270 * Route handler parameter decorator. Extracts a single property from
271 * the `body` object property of the `req` object and populates the decorated
272 * parameter with the value of that property. Also applies pipes to the bound
273 * body parameter.
274 *
275 * For example:
276 * ```typescript
277 * async create(@Body('role', new ValidationPipe()) role: string)
278 * ```
279 *
280 * @param property name of single property to extract from the `body` object
281 * @param pipes one or more pipes - either instances or classes - to apply to
282 * the bound body parameter.
283 *
284 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
285 * @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
286 *
287 * @publicApi
288 */
289export declare function Body(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
290/**
291 * Route handler parameter decorator. Extracts the `params`
292 * property from the `req` object and populates the decorated
293 * parameter with the value of `params`. May also apply pipes to the bound
294 * parameter.
295 *
296 * For example, extracting all params:
297 * ```typescript
298 * findOne(@Param() params: string[])
299 * ```
300 *
301 * For example, extracting a single param:
302 * ```typescript
303 * findOne(@Param('id') id: string)
304 * ```
305 * @param property name of single property to extract from the `req` object
306 * @param pipes one or more pipes - either instances or classes - to apply to
307 * the bound parameter.
308 *
309 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
310 * @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
311 *
312 * @publicApi
313 */
314export declare function Param(): ParameterDecorator;
315/**
316 * Route handler parameter decorator. Extracts the `params`
317 * property from the `req` object and populates the decorated
318 * parameter with the value of `params`. May also apply pipes to the bound
319 * parameter.
320 *
321 * For example, extracting all params:
322 * ```typescript
323 * findOne(@Param() params: string[])
324 * ```
325 *
326 * For example, extracting a single param:
327 * ```typescript
328 * findOne(@Param('id') id: string)
329 * ```
330 * @param property name of single property to extract from the `req` object
331 * @param pipes one or more pipes - either instances or classes - to apply to
332 * the bound parameter.
333 *
334 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
335 * @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
336 *
337 * @publicApi
338 */
339export declare function Param(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
340/**
341 * Route handler parameter decorator. Extracts the `params`
342 * property from the `req` object and populates the decorated
343 * parameter with the value of `params`. May also apply pipes to the bound
344 * parameter.
345 *
346 * For example, extracting all params:
347 * ```typescript
348 * findOne(@Param() params: string[])
349 * ```
350 *
351 * For example, extracting a single param:
352 * ```typescript
353 * findOne(@Param('id') id: string)
354 * ```
355 * @param property name of single property to extract from the `req` object
356 * @param pipes one or more pipes - either instances or classes - to apply to
357 * the bound parameter.
358 *
359 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
360 * @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
361 *
362 * @publicApi
363 */
364export declare function Param(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
365/**
366 * Route handler parameter decorator. Extracts the `hosts`
367 * property from the `req` object and populates the decorated
368 * parameter with the value of `hosts`. May also apply pipes to the bound
369 * parameter.
370 *
371 * For example, extracting all params:
372 * ```typescript
373 * findOne(@HostParam() params: string[])
374 * ```
375 *
376 * For example, extracting a single param:
377 * ```typescript
378 * findOne(@HostParam('id') id: string)
379 * ```
380 * @param property name of single property to extract from the `req` object
381 *
382 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
383 *
384 * @publicApi
385 */
386export declare function HostParam(): ParameterDecorator;
387/**
388 * Route handler parameter decorator. Extracts the `hosts`
389 * property from the `req` object and populates the decorated
390 * parameter with the value of `hosts`. May also apply pipes to the bound
391 * parameter.
392 *
393 * For example, extracting all params:
394 * ```typescript
395 * findOne(@HostParam() params: string[])
396 * ```
397 *
398 * For example, extracting a single param:
399 * ```typescript
400 * findOne(@HostParam('id') id: string)
401 * ```
402 * @param property name of single property to extract from the `req` object
403 *
404 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
405 *
406 * @publicApi
407 */
408export declare function HostParam(property: string): ParameterDecorator;
409export declare const Req: () => ParameterDecorator;
410export declare const Res: (options?: ResponseDecoratorOptions) => ParameterDecorator;