(
module: any,
container: NestContainer,
graphInspector: GraphInspector,
config = new ApplicationConfig(),
options: NestApplicationContextOptions = {},
httpServer: HttpServer | null = null,
)
| 204 | } |
| 205 | |
| 206 | private async initialize( |
| 207 | module: any, |
| 208 | container: NestContainer, |
| 209 | graphInspector: GraphInspector, |
| 210 | config = new ApplicationConfig(), |
| 211 | options: NestApplicationContextOptions = {}, |
| 212 | httpServer: HttpServer | null = null, |
| 213 | ) { |
| 214 | UuidFactory.mode = options.snapshot |
| 215 | ? UuidFactoryMode.Deterministic |
| 216 | : UuidFactoryMode.Random; |
| 217 | |
| 218 | const injector = new Injector({ |
| 219 | preview: options.preview!, |
| 220 | snapshot: options.snapshot, |
| 221 | instanceDecorator: options.instrument?.instanceDecorator, |
| 222 | }); |
| 223 | const instanceLoader = new InstanceLoader( |
| 224 | container, |
| 225 | injector, |
| 226 | graphInspector, |
| 227 | ); |
| 228 | const metadataScanner = new MetadataScanner(); |
| 229 | const dependenciesScanner = new DependenciesScanner( |
| 230 | container, |
| 231 | metadataScanner, |
| 232 | graphInspector, |
| 233 | config, |
| 234 | ); |
| 235 | container.setHttpAdapter(httpServer); |
| 236 | |
| 237 | const teardown = this.abortOnError === false ? rethrow : undefined; |
| 238 | await httpServer?.init?.(); |
| 239 | try { |
| 240 | this.logger.log(MESSAGES.APPLICATION_START); |
| 241 | |
| 242 | await ExceptionsZone.asyncRun( |
| 243 | async () => { |
| 244 | await dependenciesScanner.scan(module); |
| 245 | await instanceLoader.createInstancesOfDependencies(); |
| 246 | dependenciesScanner.applyApplicationProviders(); |
| 247 | }, |
| 248 | teardown, |
| 249 | this.autoFlushLogs, |
| 250 | ); |
| 251 | } catch (e) { |
| 252 | this.handleInitializationError(e); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | private handleInitializationError(err: unknown) { |
| 257 | if (this.abortOnError) { |
no test coverage detected