UNPKG

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