1 | import { CorsOptions, CorsOptionsDelegate } from './external/cors-options.interface';
|
2 | import { CanActivate } from './features/can-activate.interface';
|
3 | import { NestInterceptor } from './features/nest-interceptor.interface';
|
4 | import { GlobalPrefixOptions } from './global-prefix-options.interface';
|
5 | import { HttpServer } from './http/http-server.interface';
|
6 | import { ExceptionFilter, INestMicroservice, NestHybridApplicationOptions, PipeTransform } from './index';
|
7 | import { INestApplicationContext } from './nest-application-context.interface';
|
8 | import { VersioningOptions } from './version-options.interface';
|
9 | import { WebSocketAdapter } from './websockets/web-socket-adapter.interface';
|
10 | /**
|
11 | * Interface defining the core NestApplication object.
|
12 | *
|
13 | * @publicApi
|
14 | */
|
15 | export interface INestApplication<TServer = any> extends INestApplicationContext {
|
16 | /**
|
17 | * A wrapper function around HTTP adapter method: `adapter.use()`.
|
18 | * Example `app.use(cors())`
|
19 | *
|
20 | * @returns {this}
|
21 | */
|
22 | use(...args: any[]): this;
|
23 | /**
|
24 | * Enables CORS (Cross-Origin Resource Sharing)
|
25 | *
|
26 | * @returns {void}
|
27 | */
|
28 | enableCors(options?: CorsOptions | CorsOptionsDelegate<any>): void;
|
29 | /**
|
30 | * Enables Versioning for the application.
|
31 | * By default, URI-based versioning is used.
|
32 | *
|
33 | * @param {VersioningOptions} options
|
34 | * @returns {this}
|
35 | */
|
36 | enableVersioning(options?: VersioningOptions): this;
|
37 | /**
|
38 | * Starts the application.
|
39 | *
|
40 | * @param {number|string} port
|
41 | * @param {string} [hostname]
|
42 | * @param {Function} [callback] Optional callback
|
43 | * @returns {Promise} A Promise that, when resolved, is a reference to the underlying HttpServer.
|
44 | */
|
45 | listen(port: number | string, callback?: () => void): Promise<any>;
|
46 | listen(port: number | string, hostname: string, callback?: () => void): Promise<any>;
|
47 | /**
|
48 | * Returns the url the application is listening at, based on OS and IP version. Returns as an IP value either in IPv6 or IPv4
|
49 | *
|
50 | * @returns {Promise<string>} The IP where the server is listening
|
51 | */
|
52 | getUrl(): Promise<string>;
|
53 | /**
|
54 | * Registers a prefix for every HTTP route path.
|
55 | *
|
56 | * @param {string} prefix The prefix for every HTTP route path (for example `/v1/api`)
|
57 | * @param {GlobalPrefixOptions} options Global prefix options object
|
58 | * @returns {this}
|
59 | */
|
60 | setGlobalPrefix(prefix: string, options?: GlobalPrefixOptions): this;
|
61 | /**
|
62 | * Register Ws Adapter which will be used inside Gateways.
|
63 | * Use when you want to override default `socket.io` library.
|
64 | *
|
65 | * @param {WebSocketAdapter} adapter
|
66 | * @returns {this}
|
67 | */
|
68 | useWebSocketAdapter(adapter: WebSocketAdapter): this;
|
69 | /**
|
70 | * Connects microservice to the NestApplication instance. Transforms application
|
71 | * to a hybrid instance.
|
72 | *
|
73 | * @template {object} T
|
74 | * @param {T} options Microservice options object
|
75 | * @param {NestHybridApplicationOptions} hybridOptions Hybrid options object
|
76 | * @returns {INestMicroservice}
|
77 | */
|
78 | connectMicroservice<T extends object = any>(options: T, hybridOptions?: NestHybridApplicationOptions): INestMicroservice;
|
79 | /**
|
80 | * Returns array of the microservices connected to the NestApplication.
|
81 | *
|
82 | * @returns {INestMicroservice[]}
|
83 | */
|
84 | getMicroservices(): INestMicroservice[];
|
85 | /**
|
86 | * Returns the underlying native HTTP server.
|
87 | *
|
88 | * @returns {TServer}
|
89 | */
|
90 | getHttpServer(): TServer;
|
91 | /**
|
92 | * Returns the underlying HTTP adapter.
|
93 | *
|
94 | * @returns {HttpServer}
|
95 | */
|
96 | getHttpAdapter(): HttpServer;
|
97 | /**
|
98 | * Starts all connected microservices asynchronously.
|
99 | *
|
100 | * @returns {Promise}
|
101 | */
|
102 | startAllMicroservices(): Promise<this>;
|
103 | /**
|
104 | * Registers exception filters as global filters (will be used within
|
105 | * every HTTP route handler)
|
106 | *
|
107 | * @param {...ExceptionFilter} filters
|
108 | */
|
109 | useGlobalFilters(...filters: ExceptionFilter[]): this;
|
110 | /**
|
111 | * Registers pipes as global pipes (will be used within every HTTP route handler)
|
112 | *
|
113 | * @param {...PipeTransform} pipes
|
114 | */
|
115 | useGlobalPipes(...pipes: PipeTransform<any>[]): this;
|
116 | /**
|
117 | * Registers interceptors as global interceptors (will be used within
|
118 | * every HTTP route handler)
|
119 | *
|
120 | * @param {...NestInterceptor} interceptors
|
121 | */
|
122 | useGlobalInterceptors(...interceptors: NestInterceptor[]): this;
|
123 | /**
|
124 | * Registers guards as global guards (will be used within every HTTP route handler)
|
125 | *
|
126 | * @param {...CanActivate} guards
|
127 | */
|
128 | useGlobalGuards(...guards: CanActivate[]): this;
|
129 | /**
|
130 | * Terminates the application (including NestApplication, Gateways, and each connected
|
131 | * microservice)
|
132 | *
|
133 | * @returns {Promise<void>}
|
134 | */
|
135 | close(): Promise<void>;
|
136 | }
|