UNPKG

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