NestApplicationContext
class NestApplicationContext<TOptions extends NestApplicationContextOptions = NestApplicationContextOptions> extends AbstractInstanceResolver implements INestApplicationContext {
constructor(container: NestContainer, appOptions: TOptions = {} as TOptions, contextModule: Module = null, scope: Type<any>[] = new Array<Type<any>>())
protected isInitialized: false
protected injector: Injector
protected logger: Logger
protected instanceLinksHost
protected container: NestContainer
protected appOptions: TOptions
selectContextModule()
select<T>(moduleType: any): INestApplicationContext
get<TInput = any, TResult = TInput>(typeOrToken: any, options: GetOrResolveOptions = { strict: false }): TResult | Array<TResult>
resolve<TInput = any, TResult = TInput>(typeOrToken: any, contextId: ContextId = createContextId(), options: GetOrResolveOptions = { strict: false }): Promise<TResult | Array<TResult>>
registerRequestByContextId<T = any>(request: T, contextId: ContextId)
init(): Promise<this>
close(signal?: string): Promise<void>
useLogger(logger: any)
flushLogs()
flushLogsOnOverride()
enableShutdownHooks(signals: any[] = []): this
protected dispose(): Promise<void>
protected listenToShutdownSignals(signals: string[])
protected unsubscribeFromProcessSignals()
protected callInitHook(): Promise<void>
protected callDestroyHook(): Promise<void>
protected callBootstrapHook(): Promise<void>
protected callShutdownHook(signal?: string): Promise<void>
protected callBeforeShutdownHook(signal?: string): Promise<void>
protected assertNotInPreviewMode(methodName: string)
}
Subclasses
Constructor
Parameters
|
Properties
Property | Description |
---|---|
protected isInitialized: false
|
|
protected injector: Injector
|
|
protected logger: Logger
|
Read-only. |
protected instanceLinksHost
|
Read-only. |
protected container: NestContainer
|
Read-only. Declared in constructor. |
protected appOptions: TOptions
|
Read-only. Declared in constructor. |
Methods
selectContextModule() |
---|
ParametersThere are no parameters. |
select() |
---|
Allows navigating through the modules tree, for example, to pull out a specific instance from the selected module. |
get() | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Retrieves an instance (or a list of instances) of either injectable or controller, otherwise, throws exception. |
|||||||||||||||
3 overloads...Show All Hide All expand_moreOverload #1Retrieves an instance of either injectable or controller, otherwise, throws exception.
Parameters
Returns
Overload #2Retrieves an instance of either injectable or controller, otherwise, throws exception.
Parameters
Returns
Overload #3 |
resolve() | |||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Resolves transient or request-scoped instance (or a list of instances) of either injectable or controller, otherwise, throws exception. |
|||||||||||||||||||||||||||||||||||||||
4 overloads...Show All Hide All expand_moreOverload #1Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception.
Parameters
Returns
Overload #2Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception.
Parameters
Returns
Overload #3Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception.
Parameters
Returns
Overload #4Resolves transient or request-scoped instances of either injectables or controllers, otherwise, throws exception.
Parameters
Returns
|
registerRequestByContextId() | |||||||||
---|---|---|---|---|---|---|---|---|---|
Registers the request/context object for a given context ID (DI container sub-tree). |
|||||||||
Parameters
Returns
|
init() |
---|
Initializes the Nest application. Calls the Nest lifecycle events. |
ParametersThere are no parameters. Returns
|
close() |
---|
Terminates the application |
useLogger() |
---|
Sets custom logger service. Flushes buffered logs if auto flush is on. |
flushLogs() |
---|
Prints buffered logs and detaches buffer. |
ParametersThere are no parameters. Returns
|
flushLogsOnOverride() |
---|
Define that it must flush logs right after defining a custom logger. |
ParametersThere are no parameters. |
enableShutdownHooks() |
---|
Enables the usage of shutdown hooks. Will call the
|
dispose() |
---|
ParametersThere are no parameters. Returns
|
listenToShutdownSignals() |
---|
Listens to shutdown signals by listening to process events |
unsubscribeFromProcessSignals() |
---|
Unsubscribes from shutdown signals (process events) |
ParametersThere are no parameters. |
callInitHook() |
---|
Calls the |
ParametersThere are no parameters. Returns
|
callDestroyHook() |
---|
Calls the |
ParametersThere are no parameters. Returns
|
callBootstrapHook() |
---|
Calls the |
ParametersThere are no parameters. Returns
|
callShutdownHook() |
---|
Calls the |
callBeforeShutdownHook() |
---|
Calls the |
assertNotInPreviewMode() |
---|