1 | import { ShutdownSignal } from '../enums/shutdown-signal.enum';
|
2 | import { LoggerService, LogLevel } from '../services/logger.service';
|
3 | import { DynamicModule } from './modules';
|
4 | import { Type } from './type.interface';
|
5 | export interface GetOrResolveOptions {
|
6 | /**
|
7 | * If enabled, lookup will only be performed in the host module.
|
8 | * @default false
|
9 | */
|
10 | strict?: boolean;
|
11 | /**
|
12 | * If enabled, instead of returning a first instance registered under a given token,
|
13 | * a list of instances will be returned.
|
14 | * @default false
|
15 | */
|
16 | each?: boolean;
|
17 | }
|
18 | /**
|
19 | * Interface defining NestApplicationContext.
|
20 | *
|
21 | * @publicApi
|
22 | */
|
23 | export interface INestApplicationContext {
|
24 | /**
|
25 | * Allows navigating through the modules tree, for example, to pull out a specific instance from the selected module.
|
26 | * @returns {INestApplicationContext}
|
27 | */
|
28 | select<T>(module: Type<T> | DynamicModule): INestApplicationContext;
|
29 | /**
|
30 | * Retrieves an instance of either injectable or controller, otherwise, throws exception.
|
31 | * @returns {TResult}
|
32 | */
|
33 | get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol): TResult;
|
34 | /**
|
35 | * Retrieves an instance of either injectable or controller, otherwise, throws exception.
|
36 | * @returns {TResult}
|
37 | */
|
38 | get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, options: {
|
39 | strict?: boolean;
|
40 | each?: undefined | false;
|
41 | }): TResult;
|
42 | /**
|
43 | * Retrieves a list of instances of either injectables or controllers, otherwise, throws exception.
|
44 | * @returns {Array<TResult>}
|
45 | */
|
46 | get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, options: {
|
47 | strict?: boolean;
|
48 | each: true;
|
49 | }): Array<TResult>;
|
50 | /**
|
51 | * Retrieves an instance (or a list of instances) of either injectable or controller, otherwise, throws exception.
|
52 | * @returns {TResult | Array<TResult>}
|
53 | */
|
54 | get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, options?: GetOrResolveOptions): TResult | Array<TResult>;
|
55 | /**
|
56 | * Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception.
|
57 | * @returns {Array<TResult>}
|
58 | */
|
59 | resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol): Promise<TResult>;
|
60 | /**
|
61 | * Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception.
|
62 | * @returns {Array<TResult>}
|
63 | */
|
64 | resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: {
|
65 | id: number;
|
66 | }): Promise<TResult>;
|
67 | /**
|
68 | * Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception.
|
69 | * @returns {Array<TResult>}
|
70 | */
|
71 | resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: {
|
72 | id: number;
|
73 | }, options?: {
|
74 | strict?: boolean;
|
75 | each?: undefined | false;
|
76 | }): Promise<TResult>;
|
77 | /**
|
78 | * Resolves transient or request-scoped instances of either injectables or controllers, otherwise, throws exception.
|
79 | * @returns {Array<TResult>}
|
80 | */
|
81 | resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: {
|
82 | id: number;
|
83 | }, options?: {
|
84 | strict?: boolean;
|
85 | each: true;
|
86 | }): Promise<Array<TResult>>;
|
87 | /**
|
88 | * Resolves transient or request-scoped instance (or a list of instances) of either injectable or controller, otherwise, throws exception.
|
89 | * @returns {Promise<TResult | Array<TResult>>}
|
90 | */
|
91 | resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: {
|
92 | id: number;
|
93 | }, options?: GetOrResolveOptions): Promise<TResult | Array<TResult>>;
|
94 | /**
|
95 | * Registers the request/context object for a given context ID (DI container sub-tree).
|
96 | * @returns {void}
|
97 | */
|
98 | registerRequestByContextId<T = any>(request: T, contextId: {
|
99 | id: number;
|
100 | }): void;
|
101 | /**
|
102 | * Terminates the application
|
103 | * @returns {Promise<void>}
|
104 | */
|
105 | close(): Promise<void>;
|
106 | /**
|
107 | * Sets custom logger service.
|
108 | * Flushes buffered logs if auto flush is on.
|
109 | * @returns {void}
|
110 | */
|
111 | useLogger(logger: LoggerService | LogLevel[] | false): void;
|
112 | /**
|
113 | * Prints buffered logs and detaches buffer.
|
114 | * @returns {void}
|
115 | */
|
116 | flushLogs(): void;
|
117 | /**
|
118 | * Enables the usage of shutdown hooks. Will call the
|
119 | * `onApplicationShutdown` function of a provider if the
|
120 | * process receives a shutdown signal.
|
121 | *
|
122 | * @returns {this} The Nest application context instance
|
123 | */
|
124 | enableShutdownHooks(signals?: ShutdownSignal[] | string[]): this;
|
125 | /**
|
126 | * Initializes the Nest application.
|
127 | * Calls the Nest lifecycle events.
|
128 | * It isn't mandatory to call this method directly.
|
129 | *
|
130 | * @returns {Promise<this>} The NestApplicationContext instance as Promise
|
131 | */
|
132 | init(): Promise<this>;
|
133 | }
|