UNPKG

4.14 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 shouldFlushLogsOnOverride;
18 private readonly activeShutdownSignals;
19 private readonly moduleCompiler;
20 private shutdownCleanupRef?;
21 private _instanceLinksHost;
22 private _moduleRefsByDistance?;
23 private get instanceLinksHost();
24 constructor(container: NestContainer, scope?: Type<any>[], contextModule?: Module);
25 selectContextModule(): void;
26 select<T>(moduleType: Type<T> | DynamicModule): INestApplicationContext;
27 get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, options?: {
28 strict: boolean;
29 }): TResult;
30 resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, contextId?: ContextId, options?: {
31 strict: boolean;
32 }): Promise<TResult>;
33 registerRequestByContextId<T = any>(request: T, contextId: ContextId): void;
34 /**
35 * Initalizes the Nest application.
36 * Calls the Nest lifecycle events.
37 *
38 * @returns {Promise<this>} The NestApplicationContext instance as Promise
39 */
40 init(): Promise<this>;
41 close(): Promise<void>;
42 useLogger(logger: LoggerService | LogLevel[] | false): void;
43 flushLogs(): void;
44 /**
45 * Define that it must flush logs right after defining a custom logger.
46 */
47 flushLogsOnOverride(): void;
48 /**
49 * Enables the usage of shutdown hooks. Will call the
50 * `onApplicationShutdown` function of a provider if the
51 * process receives a shutdown signal.
52 *
53 * @param {ShutdownSignal[]} [signals=[]] The system signals it should listen to
54 *
55 * @returns {this} The Nest application context instance
56 */
57 enableShutdownHooks(signals?: (ShutdownSignal | string)[]): this;
58 protected dispose(): Promise<void>;
59 /**
60 * Listens to shutdown signals by listening to
61 * process events
62 *
63 * @param {string[]} signals The system signals it should listen to
64 */
65 protected listenToShutdownSignals(signals: string[]): void;
66 /**
67 * Unsubscribes from shutdown signals (process events)
68 */
69 protected unsubscribeFromProcessSignals(): void;
70 /**
71 * Calls the `onModuleInit` function on the registered
72 * modules and its children.
73 */
74 protected callInitHook(): Promise<void>;
75 /**
76 * Calls the `onModuleDestroy` function on the registered
77 * modules and its children.
78 */
79 protected callDestroyHook(): Promise<void>;
80 /**
81 * Calls the `onApplicationBootstrap` function on the registered
82 * modules and its children.
83 */
84 protected callBootstrapHook(): Promise<void>;
85 /**
86 * Calls the `onApplicationShutdown` function on the registered
87 * modules and children.
88 */
89 protected callShutdownHook(signal?: string): Promise<void>;
90 /**
91 * Calls the `beforeApplicationShutdown` function on the registered
92 * modules and children.
93 */
94 protected callBeforeShutdownHook(signal?: string): Promise<void>;
95 protected find<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, contextModule?: Module): TResult;
96 protected resolvePerContext<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, contextModule: Module, contextId: ContextId, options?: {
97 strict: boolean;
98 }): Promise<TResult>;
99 private getModulesSortedByDistance;
100}