1
1
import http = require( "http" ) ;
2
+ import type { Server as HTTPSServer } from "https" ;
2
3
import { createReadStream } from "fs" ;
3
4
import { createDeflate , createGzip , createBrotliCompress } from "zlib" ;
4
5
import accepts = require( "accepts" ) ;
@@ -131,7 +132,7 @@ export class Server<
131
132
* @private
132
133
*/
133
134
_connectTimeout : number ;
134
- private httpServer : http . Server ;
135
+ private httpServer : http . Server | HTTPSServer ;
135
136
136
137
/**
137
138
* Server constructor.
@@ -141,13 +142,26 @@ export class Server<
141
142
* @public
142
143
*/
143
144
constructor ( opts ?: Partial < ServerOptions > ) ;
144
- constructor ( srv ?: http . Server | number , opts ?: Partial < ServerOptions > ) ;
145
145
constructor (
146
- srv : undefined | Partial < ServerOptions > | http . Server | number ,
146
+ srv ?: http . Server | HTTPSServer | number ,
147
147
opts ?: Partial < ServerOptions >
148
148
) ;
149
149
constructor (
150
- srv : undefined | Partial < ServerOptions > | http . Server | number ,
150
+ srv :
151
+ | undefined
152
+ | Partial < ServerOptions >
153
+ | http . Server
154
+ | HTTPSServer
155
+ | number ,
156
+ opts ?: Partial < ServerOptions >
157
+ ) ;
158
+ constructor (
159
+ srv :
160
+ | undefined
161
+ | Partial < ServerOptions >
162
+ | http . Server
163
+ | HTTPSServer
164
+ | number ,
151
165
opts : Partial < ServerOptions > = { }
152
166
) {
153
167
super ( ) ;
@@ -167,7 +181,8 @@ export class Server<
167
181
this . adapter ( opts . adapter || Adapter ) ;
168
182
this . sockets = this . of ( "/" ) ;
169
183
this . opts = opts ;
170
- if ( srv || typeof srv == "number" ) this . attach ( srv as http . Server | number ) ;
184
+ if ( srv || typeof srv == "number" )
185
+ this . attach ( srv as http . Server | HTTPSServer | number ) ;
171
186
}
172
187
173
188
/**
@@ -300,7 +315,7 @@ export class Server<
300
315
* @public
301
316
*/
302
317
public listen (
303
- srv : http . Server | number ,
318
+ srv : http . Server | HTTPSServer | number ,
304
319
opts : Partial < ServerOptions > = { }
305
320
) : this {
306
321
return this . attach ( srv , opts ) ;
@@ -315,7 +330,7 @@ export class Server<
315
330
* @public
316
331
*/
317
332
public attach (
318
- srv : http . Server | number ,
333
+ srv : http . Server | HTTPSServer | number ,
319
334
opts : Partial < ServerOptions > = { }
320
335
) : this {
321
336
if ( "function" == typeof srv ) {
@@ -421,7 +436,7 @@ export class Server<
421
436
* @private
422
437
*/
423
438
private initEngine (
424
- srv : http . Server ,
439
+ srv : http . Server | HTTPSServer ,
425
440
opts : EngineOptions & AttachOptions
426
441
) : void {
427
442
// initialize engine
@@ -444,7 +459,7 @@ export class Server<
444
459
* @param srv http server
445
460
* @private
446
461
*/
447
- private attachServe ( srv : http . Server ) : void {
462
+ private attachServe ( srv : http . Server | HTTPSServer ) : void {
448
463
debug ( "attaching client serving req handler" ) ;
449
464
450
465
const evs = srv . listeners ( "request" ) . slice ( 0 ) ;
0 commit comments