UNPKG

3.98 kBTypeScriptView Raw
1import { INestApplicationContext, LoggerService, LogLevel, ShutdownSignal } from '@nestjs/common';
2import { Abstract, DynamicModule } from '@nestjs/common/interfaces';
3import { Type } from '@nestjs/common/interfaces/type.interface';
4import { NestContainer } from './injector/container';
5import { Injector } from './injector/injector';
6import { ContextId } from './injector/instance-wrapper';
7import { Module } from './injector/module';
8/**
9 * @publicApi
10 */
11export declare class NestApplicationContext implements INestApplicationContext {
12 protected readonly container: NestContainer;
13 private readonly scope;
14 private contextModule;
15 protected isInitialized: boolean;
16 protected readonly injector: Injector;
17 private readonly activeShutdownSignals;
18 private readonly moduleCompiler;
19 private shutdownCleanupRef?;
20 private _instanceLinksHost;
21 private _moduleRefsByDistance?;
22 private get instanceLinksHost();
23 constructor(container: NestContainer, scope?: Type<any>[], contextModule?: Module);
24 selectContextModule(): void;
25 select<T>(moduleType: Type<T> | DynamicModule): INestApplicationContext;
26 get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, options?: {
27 strict: boolean;
28 }): TResult;
29 resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, contextId?: ContextId, options?: {
30 strict: boolean;
31 }): Promise<TResult>;
32 registerRequestByContextId<T = any>(request: T, contextId: ContextId): void;
33 /**
34 * Initalizes the Nest application.
35 * Calls the Nest lifecycle events.
36 *
37 * @returns {Promise<this>} The NestApplicationContext instance as Promise
38 */
39 init(): Promise<this>;
40 close(): Promise<void>;
41 useLogger(logger: LoggerService | LogLevel[] | false): void;
42 flushLogs(): void;
43 /**
44 * Enables the usage of shutdown hooks. Will call the
45 * `onApplicationShutdown` function of a provider if the
46 * process receives a shutdown signal.
47 *
48 * @param {ShutdownSignal[]} [signals=[]] The system signals it should listen to
49 *
50 * @returns {this} The Nest application context instance
51 */
52 enableShutdownHooks(signals?: (ShutdownSignal | string)[]): this;
53 protected dispose(): Promise<void>;
54 /**
55 * Listens to shutdown signals by listening to
56 * process events
57 *
58 * @param {string[]} signals The system signals it should listen to
59 */
60 protected listenToShutdownSignals(signals: string[]): void;
61 /**
62 * Unsubscribes from shutdown signals (process events)
63 */
64 protected unsubscribeFromProcessSignals(): void;
65 /**
66 * Calls the `onModuleInit` function on the registered
67 * modules and its children.
68 */
69 protected callInitHook(): Promise<void>;
70 /**
71 * Calls the `onModuleDestroy` function on the registered
72 * modules and its children.
73 */
74 protected callDestroyHook(): Promise<void>;
75 /**
76 * Calls the `onApplicationBootstrap` function on the registered
77 * modules and its children.
78 */
79 protected callBootstrapHook(): Promise<void>;
80 /**
81 * Calls the `onApplicationShutdown` function on the registered
82 * modules and children.
83 */
84 protected callShutdownHook(signal?: string): Promise<void>;
85 /**
86 * Calls the `beforeApplicationShutdown` function on the registered
87 * modules and children.
88 */
89 protected callBeforeShutdownHook(signal?: string): Promise<void>;
90 protected find<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, contextModule?: Module): TResult;
91 protected resolvePerContext<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, contextModule: Module, contextId: ContextId, options?: {
92 strict: boolean;
93 }): Promise<TResult>;
94 private getModulesSortedByDistance;
95}