UNPKG

15.3 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 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 `rawBody` Buffer
292 * property from the `req` object and populates the decorated parameter with that value.
293 *
294 * For example:
295 * ```typescript
296 * async create(@RawBody() rawBody: Buffer | undefined)
297 * ```
298 *
299 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
300 * @see [Raw body](https://docs.nestjs.com/faq/raw-body)
301 *
302 * @publicApi
303 */
304export declare function RawBody(): ParameterDecorator;
305/**
306 * Route handler parameter decorator. Extracts the `rawBody` Buffer
307 * property from the `req` object and populates the decorated parameter with that value.
308 * Also applies pipes to the bound rawBody parameter.
309 *
310 * For example:
311 * ```typescript
312 * async create(@RawBody(new ValidationPipe()) rawBody: Buffer)
313 * ```
314 *
315 * @param pipes one or more pipes - either instances or classes - to apply to
316 * the bound body parameter.
317 *
318 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
319 * @see [Raw body](https://docs.nestjs.com/faq/raw-body)
320 * @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
321 *
322 * @publicApi
323 */
324export declare function RawBody(...pipes: (Type<PipeTransform<Buffer | undefined>> | PipeTransform<Buffer | undefined>)[]): ParameterDecorator;
325/**
326 * Route handler parameter decorator. Extracts the `params`
327 * property from the `req` object and populates the decorated
328 * parameter with the value of `params`. May also apply pipes to the bound
329 * parameter.
330 *
331 * For example, extracting all params:
332 * ```typescript
333 * findOne(@Param() params: string[])
334 * ```
335 *
336 * For example, extracting a single param:
337 * ```typescript
338 * findOne(@Param('id') id: string)
339 * ```
340 * @param property name of single property to extract from the `req` object
341 * @param pipes one or more pipes - either instances or classes - to apply to
342 * the bound parameter.
343 *
344 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
345 * @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
346 *
347 * @publicApi
348 */
349export declare function Param(): ParameterDecorator;
350/**
351 * Route handler parameter decorator. Extracts the `params`
352 * property from the `req` object and populates the decorated
353 * parameter with the value of `params`. May also apply pipes to the bound
354 * parameter.
355 *
356 * For example, extracting all params:
357 * ```typescript
358 * findOne(@Param() params: string[])
359 * ```
360 *
361 * For example, extracting a single param:
362 * ```typescript
363 * findOne(@Param('id') id: string)
364 * ```
365 * @param property name of single property to extract from the `req` object
366 * @param pipes one or more pipes - either instances or classes - to apply to
367 * the bound parameter.
368 *
369 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
370 * @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
371 *
372 * @publicApi
373 */
374export declare function Param(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
375/**
376 * Route handler parameter decorator. Extracts the `params`
377 * property from the `req` object and populates the decorated
378 * parameter with the value of `params`. May also apply pipes to the bound
379 * parameter.
380 *
381 * For example, extracting all params:
382 * ```typescript
383 * findOne(@Param() params: string[])
384 * ```
385 *
386 * For example, extracting a single param:
387 * ```typescript
388 * findOne(@Param('id') id: string)
389 * ```
390 * @param property name of single property to extract from the `req` object
391 * @param pipes one or more pipes - either instances or classes - to apply to
392 * the bound parameter.
393 *
394 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
395 * @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
396 *
397 * @publicApi
398 */
399export declare function Param(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
400/**
401 * Route handler parameter decorator. Extracts the `hosts`
402 * property from the `req` object and populates the decorated
403 * parameter with the value of `hosts`. May also apply pipes to the bound
404 * parameter.
405 *
406 * For example, extracting all params:
407 * ```typescript
408 * findOne(@HostParam() params: string[])
409 * ```
410 *
411 * For example, extracting a single param:
412 * ```typescript
413 * findOne(@HostParam('id') id: string)
414 * ```
415 * @param property name of single property to extract from the `req` object
416 *
417 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
418 *
419 * @publicApi
420 */
421export declare function HostParam(): ParameterDecorator;
422/**
423 * Route handler parameter decorator. Extracts the `hosts`
424 * property from the `req` object and populates the decorated
425 * parameter with the value of `hosts`. May also apply pipes to the bound
426 * parameter.
427 *
428 * For example, extracting all params:
429 * ```typescript
430 * findOne(@HostParam() params: string[])
431 * ```
432 *
433 * For example, extracting a single param:
434 * ```typescript
435 * findOne(@HostParam('id') id: string)
436 * ```
437 * @param property name of single property to extract from the `req` object
438 *
439 * @see [Request object](https://docs.nestjs.com/controllers#request-object)
440 *
441 * @publicApi
442 */
443export declare function HostParam(property: string): ParameterDecorator;
444export declare const Req: () => ParameterDecorator;
445export declare const Res: (options?: ResponseDecoratorOptions) => ParameterDecorator;