UNPKG

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