INestApplication
Interface defining the core NestApplication object.
interface INestApplication extends INestApplicationContext {
use(...args: any[]): this
enableCors(options?: CorsOptions | CorsOptionsDelegate<any>): void
enableVersioning(options?: VersioningOptions): this
listen(port: string | number, callback?: () => void): Promise<any>
getUrl(): Promise<string>
setGlobalPrefix(prefix: string, options?: GlobalPrefixOptions<string | RouteInfo>): this
useWebSocketAdapter(adapter: WebSocketAdapter<any, any, any>): this
connectMicroservice<T extends object = any>(options: T, hybridOptions?: NestHybridApplicationOptions): INestMicroservice
getMicroservices(): INestMicroservice[]
getHttpServer(): any
getHttpAdapter(): HttpServer
startAllMicroservices(): Promise<this>
useGlobalFilters(...filters: ExceptionFilter<any>[]): this
useGlobalPipes(...pipes: PipeTransform<any, any>[]): this
useGlobalInterceptors(...interceptors: NestInterceptor<any, any>[]): this
useGlobalGuards(...guards: CanActivate[]): this
close(): Promise<void>
// inherited from nest/packages/common/INestApplicationContext
select<T>(module: Type<T> | DynamicModule): INestApplicationContext
get<TInput = any, TResult = TInput>(typeOrToken: string | symbol | Function | Type<TInput>): TResult
resolve<TInput = any, TResult = TInput>(typeOrToken: string | symbol | Function | Type<TInput>): Promise<TResult>
registerRequestByContextId<T = any>(request: T, contextId: { id: number; }): void
close(): Promise<void>
useLogger(logger: false | LoggerService | LogLevel[]): void
flushLogs(): void
enableShutdownHooks(signals?: string[] | ShutdownSignal[]): this
init(): Promise<this>
}
Methods
use() |
---|
A wrapper function around HTTP adapter method: |
enableCors() |
---|
Enables CORS (Cross-Origin Resource Sharing) |
enableVersioning() | ||||||
---|---|---|---|---|---|---|
Enables Versioning for the application. By default, URI-based versioning is used. |
||||||
Parameters
Returns
|
listen() |
---|
Starts the application. |
getUrl() |
---|
Returns the url the application is listening at, based on OS and IP version. Returns as an IP value either in IPv6 or IPv4 |
ParametersThere are no parameters. Returns
|
useWebSocketAdapter() | ||||||
---|---|---|---|---|---|---|
Register Ws Adapter which will be used inside Gateways.
Use when you want to override default |
||||||
Parameters
Returns
|
connectMicroservice() | |||||||||
---|---|---|---|---|---|---|---|---|---|
Connects microservice to the NestApplication instance. Transforms application to a hybrid instance. |
|||||||||
Parameters
Returns |
getMicroservices() |
---|
Returns array of the microservices connected to the NestApplication. |
ParametersThere are no parameters. Returns |
getHttpServer() |
---|
Returns the underlying native HTTP server. |
ParametersThere are no parameters. Returns
|
getHttpAdapter() |
---|
Returns the underlying HTTP adapter. |
startAllMicroservices() |
---|
Starts all connected microservices asynchronously. |
ParametersThere are no parameters. Returns
|
useGlobalFilters() | ||||||
---|---|---|---|---|---|---|
Registers exception filters as global filters (will be used within every HTTP route handler) |
||||||
Parameters
Returns
|
useGlobalPipes() | ||||||
---|---|---|---|---|---|---|
Registers pipes as global pipes (will be used within every HTTP route handler) |
||||||
Parameters
Returns
|
useGlobalInterceptors() | ||||||
---|---|---|---|---|---|---|
Registers interceptors as global interceptors (will be used within every HTTP route handler) |
||||||
Parameters
Returns
|
useGlobalGuards() | ||||||
---|---|---|---|---|---|---|
Registers guards as global guards (will be used within every HTTP route handler) |
||||||
Parameters
Returns
|
close() |
---|
Terminates the application (including NestApplication, Gateways, and each connected microservice) |
ParametersThere are no parameters. Returns
|