UNPKG

4.66 kBTypeScriptView Raw
1import { ScopeOptions, VersionOptions } from '../../interfaces';
2/**
3 * Interface defining options that can be passed to `@Controller()` decorator
4 *
5 * @publicApi
6 */
7export interface ControllerOptions extends ScopeOptions, VersionOptions {
8 /**
9 * Specifies an optional `route path prefix`. The prefix is pre-pended to the
10 * path specified in any request decorator in the class.
11 *
12 * Supported only by HTTP-based applications (does not apply to non-HTTP microservices).
13 *
14 * @see [Routing](https://docs.nestjs.com/controllers#routing)
15 */
16 path?: string | string[];
17 /**
18 * Specifies an optional HTTP Request host filter. When configured, methods
19 * within the controller will only be routed if the request host matches the
20 * specified value.
21 *
22 * @see [Routing](https://docs.nestjs.com/controllers#routing)
23 */
24 host?: string | RegExp | Array<string | RegExp>;
25}
26/**
27 * Decorator that marks a class as a Nest controller that can receive inbound
28 * requests and produce responses.
29 *
30 * An HTTP Controller responds to inbound HTTP Requests and produces HTTP Responses.
31 * It defines a class that provides the context for one or more related route
32 * handlers that correspond to HTTP request methods and associated routes
33 * for example `GET /api/profile`, `POST /users/resume`.
34 *
35 * A Microservice Controller responds to requests as well as events, running over
36 * a variety of transports [(read more here)](https://docs.nestjs.com/microservices/basics).
37 * It defines a class that provides a context for one or more message or event
38 * handlers.
39 *
40 * @see [Controllers](https://docs.nestjs.com/controllers)
41 * @see [Microservices](https://docs.nestjs.com/microservices/basics#request-response)
42 *
43 * @publicApi
44 */
45export declare function Controller(): ClassDecorator;
46/**
47 * Decorator that marks a class as a Nest controller that can receive inbound
48 * requests and produce responses.
49 *
50 * An HTTP Controller responds to inbound HTTP Requests and produces HTTP Responses.
51 * It defines a class that provides the context for one or more related route
52 * handlers that correspond to HTTP request methods and associated routes
53 * for example `GET /api/profile`, `POST /users/resume`.
54 *
55 * A Microservice Controller responds to requests as well as events, running over
56 * a variety of transports [(read more here)](https://docs.nestjs.com/microservices/basics).
57 * It defines a class that provides a context for one or more message or event
58 * handlers.
59 *
60 * @param {string|Array} prefix string that defines a `route path prefix`. The prefix
61 * is pre-pended to the path specified in any request decorator in the class.
62 *
63 * @see [Routing](https://docs.nestjs.com/controllers#routing)
64 * @see [Controllers](https://docs.nestjs.com/controllers)
65 * @see [Microservices](https://docs.nestjs.com/microservices/basics#request-response)
66 *
67 * @publicApi
68 */
69export declare function Controller(prefix: string | string[]): ClassDecorator;
70/**
71 * Decorator that marks a class as a Nest controller that can receive inbound
72 * requests and produce responses.
73 *
74 * An HTTP Controller responds to inbound HTTP Requests and produces HTTP Responses.
75 * It defines a class that provides the context for one or more related route
76 * handlers that correspond to HTTP request methods and associated routes
77 * for example `GET /api/profile`, `POST /users/resume`.
78 *
79 * A Microservice Controller responds to requests as well as events, running over
80 * a variety of transports [(read more here)](https://docs.nestjs.com/microservices/basics).
81 * It defines a class that provides a context for one or more message or event
82 * handlers.
83 *
84 * @param {object} options configuration object specifying:
85 *
86 * - `scope` - symbol that determines the lifetime of a Controller instance.
87 * [See Scope](https://docs.nestjs.com/fundamentals/injection-scopes#usage) for
88 * more details.
89 * - `prefix` - string that defines a `route path prefix`. The prefix
90 * is pre-pended to the path specified in any request decorator in the class.
91 * - `version` - string, array of strings, or Symbol that defines the version
92 * of all routes in the class. [See Versioning](https://docs.nestjs.com/techniques/versioning)
93 * for more details.
94 *
95 * @see [Routing](https://docs.nestjs.com/controllers#routing)
96 * @see [Controllers](https://docs.nestjs.com/controllers)
97 * @see [Microservices](https://docs.nestjs.com/microservices/basics#request-response)
98 * @see [Versioning](https://docs.nestjs.com/techniques/versioning)
99 *
100 * @publicApi
101 */
102export declare function Controller(options: ControllerOptions): ClassDecorator;