UNPKG

2.47 kBTypeScriptView Raw
1import { ShutdownSignal } from '../enums/shutdown-signal.enum';
2import { LoggerService, LogLevel } from '../services/logger.service';
3import { DynamicModule } from './modules';
4import { Type } from './type.interface';
5/**
6 * Interface defining NestApplicationContext.
7 *
8 * @publicApi
9 */
10export interface INestApplicationContext {
11 /**
12 * Allows navigating through the modules tree, for example, to pull out a specific instance from the selected module.
13 * @returns {INestApplicationContext}
14 */
15 select<T>(module: Type<T> | DynamicModule): INestApplicationContext;
16 /**
17 * Retrieves an instance of either injectable or controller, otherwise, throws exception.
18 * @returns {TResult}
19 */
20 get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, options?: {
21 strict: boolean;
22 }): TResult;
23 /**
24 * Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception.
25 * @returns {Promise<TResult>}
26 */
27 resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: {
28 id: number;
29 }, options?: {
30 strict: boolean;
31 }): Promise<TResult>;
32 /**
33 * Registers the request/context object for a given context ID (DI container sub-tree).
34 * @returns {void}
35 */
36 registerRequestByContextId<T = any>(request: T, contextId: {
37 id: number;
38 }): void;
39 /**
40 * Terminates the application
41 * @returns {Promise<void>}
42 */
43 close(): Promise<void>;
44 /**
45 * Sets custom logger service.
46 * Flushes buffered logs if auto flush is on.
47 * @returns {void}
48 */
49 useLogger(logger: LoggerService | LogLevel[] | false): void;
50 /**
51 * Prints buffered logs and detaches buffer.
52 * @returns {void}
53 */
54 flushLogs(): void;
55 /**
56 * Enables the usage of shutdown hooks. Will call the
57 * `onApplicationShutdown` function of a provider if the
58 * process receives a shutdown signal.
59 *
60 * @returns {this} The Nest application context instance
61 */
62 enableShutdownHooks(signals?: ShutdownSignal[] | string[]): this;
63 /**
64 * Initalizes the Nest application.
65 * Calls the Nest lifecycle events.
66 * It isn't mandatory to call this method directly.
67 *
68 * @returns {Promise<this>} The NestApplicationContext instance as Promise
69 */
70 init(): Promise<this>;
71}