import { ShutdownSignal } from '../enums/shutdown-signal.enum'; import { LoggerService, LogLevel } from '../services/logger.service'; import { DynamicModule } from './modules'; import { Type } from './type.interface'; export interface GetOrResolveOptions { /** * If enabled, lookup will only be performed in the host module. * @default false */ strict?: boolean; /** * If enabled, instead of returning a first instance registered under a given token, * a list of instances will be returned. * @default false */ each?: boolean; } /** * Interface defining NestApplicationContext. * * @publicApi */ export interface INestApplicationContext { /** * Allows navigating through the modules tree, for example, to pull out a specific instance from the selected module. * @returns {INestApplicationContext} */ select(module: Type | DynamicModule): INestApplicationContext; /** * Retrieves an instance of either injectable or controller, otherwise, throws exception. * @returns {TResult} */ get(typeOrToken: Type | Function | string | symbol): TResult; /** * Retrieves an instance of either injectable or controller, otherwise, throws exception. * @returns {TResult} */ get(typeOrToken: Type | Function | string | symbol, options: { strict?: boolean; each?: undefined | false; }): TResult; /** * Retrieves a list of instances of either injectables or controllers, otherwise, throws exception. * @returns {Array} */ get(typeOrToken: Type | Function | string | symbol, options: { strict?: boolean; each: true; }): Array; /** * Retrieves an instance (or a list of instances) of either injectable or controller, otherwise, throws exception. * @returns {TResult | Array} */ get(typeOrToken: Type | Function | string | symbol, options?: GetOrResolveOptions): TResult | Array; /** * Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception. * @returns {Array} */ resolve(typeOrToken: Type | Function | string | symbol): Promise; /** * Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception. * @returns {Array} */ resolve(typeOrToken: Type | Function | string | symbol, contextId?: { id: number; }): Promise; /** * Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception. * @returns {Array} */ resolve(typeOrToken: Type | Function | string | symbol, contextId?: { id: number; }, options?: { strict?: boolean; each?: undefined | false; }): Promise; /** * Resolves transient or request-scoped instances of either injectables or controllers, otherwise, throws exception. * @returns {Array} */ resolve(typeOrToken: Type | Function | string | symbol, contextId?: { id: number; }, options?: { strict?: boolean; each: true; }): Promise>; /** * Resolves transient or request-scoped instance (or a list of instances) of either injectable or controller, otherwise, throws exception. * @returns {Promise>} */ resolve(typeOrToken: Type | Function | string | symbol, contextId?: { id: number; }, options?: GetOrResolveOptions): Promise>; /** * Registers the request/context object for a given context ID (DI container sub-tree). * @returns {void} */ registerRequestByContextId(request: T, contextId: { id: number; }): void; /** * Terminates the application * @returns {Promise} */ close(): Promise; /** * Sets custom logger service. * Flushes buffered logs if auto flush is on. * @returns {void} */ useLogger(logger: LoggerService | LogLevel[] | false): void; /** * Prints buffered logs and detaches buffer. * @returns {void} */ flushLogs(): void; /** * Enables the usage of shutdown hooks. Will call the * `onApplicationShutdown` function of a provider if the * process receives a shutdown signal. * * @returns {this} The Nest application context instance */ enableShutdownHooks(signals?: ShutdownSignal[] | string[]): this; /** * Initializes the Nest application. * Calls the Nest lifecycle events. * It isn't mandatory to call this method directly. * * @returns {Promise} The NestApplicationContext instance as Promise */ init(): Promise; }