| 52 | * @publicApi |
| 53 | */ |
| 54 | export class NestApplication |
| 55 | extends NestApplicationContext<NestApplicationOptions> |
| 56 | implements INestApplication |
| 57 | { |
| 58 | protected readonly logger = new Logger(NestApplication.name, { |
| 59 | timestamp: true, |
| 60 | }); |
| 61 | private readonly middlewareModule: MiddlewareModule; |
| 62 | private readonly middlewareContainer = new MiddlewareContainer( |
| 63 | this.container, |
| 64 | ); |
| 65 | private readonly microservicesModule = |
| 66 | MicroservicesModule && new MicroservicesModule(); |
| 67 | private readonly socketModule = SocketModule && new SocketModule(); |
| 68 | private readonly routesResolver: Resolver; |
| 69 | private readonly microservices: any[] = []; |
| 70 | private httpServer: any; |
| 71 | private isListening = false; |
| 72 | private isWsModuleRegistered = false; |
| 73 | |
| 74 | constructor( |
| 75 | container: NestContainer, |
| 76 | private readonly httpAdapter: HttpServer, |
| 77 | private readonly config: ApplicationConfig, |
| 78 | private readonly graphInspector: GraphInspector, |
| 79 | appOptions: NestApplicationOptions = {}, |
| 80 | ) { |
| 81 | super(container, appOptions); |
| 82 | |
| 83 | this.selectContextModule(); |
| 84 | this.registerHttpServer(); |
| 85 | this.injector = new Injector({ |
| 86 | preview: this.appOptions.preview!, |
| 87 | instanceDecorator: appOptions.instrument?.instanceDecorator, |
| 88 | }); |
| 89 | this.middlewareModule = new MiddlewareModule(); |
| 90 | this.routesResolver = new RoutesResolver( |
| 91 | this.container, |
| 92 | this.config, |
| 93 | this.injector, |
| 94 | this.graphInspector, |
| 95 | ); |
| 96 | } |
| 97 | |
| 98 | protected async dispose(): Promise<void> { |
| 99 | this.socketModule && (await this.socketModule.close()); |
| 100 | this.microservicesModule && (await this.microservicesModule.close()); |
| 101 | this.httpAdapter && (await this.httpAdapter.close()); |
| 102 | |
| 103 | await Promise.all( |
| 104 | iterate(this.microservices).map(async microservice => { |
| 105 | microservice.setIsTerminated(true); |
| 106 | await microservice.close(); |
| 107 | }), |
| 108 | ); |
| 109 | } |
| 110 | |
| 111 | public getHttpAdapter(): AbstractHttpAdapter { |
nothing calls this directly
no outgoing calls
no test coverage detected