Skip to content

Commit 9b43c91

Browse files
h110mdarrachequesne
authored andcommitted
fix(typings): add HTTPS server to accepted types (#4351)
1 parent 8ecfcba commit 9b43c91

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

lib/index.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import http = require("http");
2+
import type { Server as HTTPSServer } from "https";
23
import { createReadStream } from "fs";
34
import { createDeflate, createGzip, createBrotliCompress } from "zlib";
45
import accepts = require("accepts");
@@ -131,7 +132,7 @@ export class Server<
131132
* @private
132133
*/
133134
_connectTimeout: number;
134-
private httpServer: http.Server;
135+
private httpServer: http.Server | HTTPSServer;
135136

136137
/**
137138
* Server constructor.
@@ -141,13 +142,26 @@ export class Server<
141142
* @public
142143
*/
143144
constructor(opts?: Partial<ServerOptions>);
144-
constructor(srv?: http.Server | number, opts?: Partial<ServerOptions>);
145145
constructor(
146-
srv: undefined | Partial<ServerOptions> | http.Server | number,
146+
srv?: http.Server | HTTPSServer | number,
147147
opts?: Partial<ServerOptions>
148148
);
149149
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,
151165
opts: Partial<ServerOptions> = {}
152166
) {
153167
super();
@@ -167,7 +181,8 @@ export class Server<
167181
this.adapter(opts.adapter || Adapter);
168182
this.sockets = this.of("/");
169183
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);
171186
}
172187

173188
/**
@@ -300,7 +315,7 @@ export class Server<
300315
* @public
301316
*/
302317
public listen(
303-
srv: http.Server | number,
318+
srv: http.Server | HTTPSServer | number,
304319
opts: Partial<ServerOptions> = {}
305320
): this {
306321
return this.attach(srv, opts);
@@ -315,7 +330,7 @@ export class Server<
315330
* @public
316331
*/
317332
public attach(
318-
srv: http.Server | number,
333+
srv: http.Server | HTTPSServer | number,
319334
opts: Partial<ServerOptions> = {}
320335
): this {
321336
if ("function" == typeof srv) {
@@ -421,7 +436,7 @@ export class Server<
421436
* @private
422437
*/
423438
private initEngine(
424-
srv: http.Server,
439+
srv: http.Server | HTTPSServer,
425440
opts: EngineOptions & AttachOptions
426441
): void {
427442
// initialize engine
@@ -444,7 +459,7 @@ export class Server<
444459
* @param srv http server
445460
* @private
446461
*/
447-
private attachServe(srv: http.Server): void {
462+
private attachServe(srv: http.Server | HTTPSServer): void {
448463
debug("attaching client serving req handler");
449464

450465
const evs = srv.listeners("request").slice(0);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy