* Creates an instance of NestApplicationContext. * * @param moduleCls Entry (root) application module class * @param options Optional Nest application configuration * * @returns A promise that, when resolved, * contains a reference to the NestApplicationContext instance.
(
moduleCls: IEntryNestModule,
options?: NestApplicationContextOptions,
)
| 169 | * contains a reference to the NestApplicationContext instance. |
| 170 | */ |
| 171 | public async createApplicationContext( |
| 172 | moduleCls: IEntryNestModule, |
| 173 | options?: NestApplicationContextOptions, |
| 174 | ): Promise<INestApplicationContext> { |
| 175 | const applicationConfig = new ApplicationConfig(); |
| 176 | const container = new NestContainer(applicationConfig, options); |
| 177 | const graphInspector = this.createGraphInspector(options!, container); |
| 178 | |
| 179 | this.setAbortOnError(options); |
| 180 | this.registerLoggerConfiguration(options); |
| 181 | |
| 182 | await this.initialize( |
| 183 | moduleCls, |
| 184 | container, |
| 185 | graphInspector, |
| 186 | applicationConfig, |
| 187 | options, |
| 188 | ); |
| 189 | |
| 190 | const modules = container.getModules().values(); |
| 191 | const root = modules.next().value; |
| 192 | |
| 193 | const context = this.createNestInstance<NestApplicationContext>( |
| 194 | new NestApplicationContext(container, options, root), |
| 195 | ); |
| 196 | if (this.autoFlushLogs) { |
| 197 | context.flushLogsOnOverride(); |
| 198 | } |
| 199 | return context.init(); |
| 200 | } |
| 201 | |
| 202 | private createNestInstance<T>(instance: T): T { |
| 203 | return this.createProxy(instance); |
no test coverage detected