|
1 | | -import { Inject, Injectable, Logger, OnApplicationBootstrap } from '@nestjs/common'; |
2 | | -import { HttpAdapterHost } from '@nestjs/core'; |
3 | | -import { ConfigService } from '@nestjs/config'; |
4 | | -import { Server } from 'http'; |
5 | | - |
6 | | -@Injectable() |
7 | | -export class AppService implements OnApplicationBootstrap { |
8 | | - private readonly logger: Logger = new Logger(AppService.name); |
9 | | - |
10 | | - constructor( |
11 | | - private readonly refHost: HttpAdapterHost<any>, |
12 | | - @Inject(ConfigService) private configService: ConfigService |
13 | | - ) {} |
14 | | - |
15 | | - onApplicationBootstrap() { |
16 | | - const server: Server = this.refHost.httpAdapter.getHttpServer(); |
17 | | - const { timeout, headersTimeout, keepAliveTimeout } = server; |
18 | | - server.timeout = parseInt(this.configService.get('SERVER_TIMEOUT', timeout.toString())); |
19 | | - this.logger.log(`server.timeout is ${server.timeout}`); |
20 | | - server.headersTimeout = parseInt(this.configService.get('SERVER_HEADERS_TIMEOUT', headersTimeout.toString())); |
21 | | - this.logger.log(`server.headersTimeout is ${server.headersTimeout}`); |
22 | | - server.keepAliveTimeout = parseInt(this.configService.get('SERVER_KEEP_ALIVE_TIMEOUT', keepAliveTimeout.toString())); |
23 | | - this.logger.log(`server.keepAliveTimeout is ${server.keepAliveTimeout}`); |
24 | | - } |
25 | | -} |
| 1 | +import { Inject, Injectable, Logger, OnApplicationBootstrap } from '@nestjs/common'; |
| 2 | +import { HttpAdapterHost } from '@nestjs/core'; |
| 3 | +import { ConfigService } from '@nestjs/config'; |
| 4 | +import { Server } from 'http'; |
| 5 | + |
| 6 | +@Injectable() |
| 7 | +export class AppService implements OnApplicationBootstrap { |
| 8 | + private readonly logger: Logger = new Logger(AppService.name); |
| 9 | + |
| 10 | + constructor( |
| 11 | + private readonly refHost: HttpAdapterHost<any>, |
| 12 | + @Inject(ConfigService) private configService: ConfigService |
| 13 | + ) {} |
| 14 | + |
| 15 | + onApplicationBootstrap() { |
| 16 | + const server: Server = this.refHost.httpAdapter.getHttpServer(); |
| 17 | + const { timeout, headersTimeout, keepAliveTimeout } = server; |
| 18 | + server.timeout = parseInt(this.configService.get('SERVER_TIMEOUT', timeout.toString())); |
| 19 | + this.logger.log(`server.timeout is ${server.timeout}`); |
| 20 | + server.headersTimeout = parseInt(this.configService.get('SERVER_HEADERS_TIMEOUT', headersTimeout.toString())); |
| 21 | + this.logger.log(`server.headersTimeout is ${server.headersTimeout}`); |
| 22 | + server.keepAliveTimeout = parseInt( |
| 23 | + this.configService.get('SERVER_KEEP_ALIVE_TIMEOUT', keepAliveTimeout.toString()) |
| 24 | + ); |
| 25 | + this.logger.log(`server.keepAliveTimeout is ${server.keepAliveTimeout}`); |
| 26 | + } |
| 27 | +} |
0 commit comments