Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add https.Server to accepted types #4351

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 10 additions & 9 deletions lib/index.ts
@@ -1,4 +1,5 @@
import http = require("http");
import https = require("https");
import { createReadStream } from "fs";
import { createDeflate, createGzip, createBrotliCompress } from "zlib";
import accepts = require("accepts");
Expand Down Expand Up @@ -131,7 +132,7 @@ export class Server<
* @private
*/
_connectTimeout: number;
private httpServer: http.Server;
private httpServer: http.Server | https.Server;

/**
* Server constructor.
Expand All @@ -141,13 +142,13 @@ export class Server<
* @public
*/
constructor(opts?: Partial<ServerOptions>);
constructor(srv?: http.Server | number, opts?: Partial<ServerOptions>);
constructor(srv?: http.Server | https.Server | number, opts?: Partial<ServerOptions>);
constructor(
srv: undefined | Partial<ServerOptions> | http.Server | number,
srv: undefined | Partial<ServerOptions> | http.Server | https.Server | number,
opts?: Partial<ServerOptions>
);
constructor(
srv: undefined | Partial<ServerOptions> | http.Server | number,
srv: undefined | Partial<ServerOptions> | http.Server | https.Server | number,
opts: Partial<ServerOptions> = {}
) {
super();
Expand All @@ -167,7 +168,7 @@ export class Server<
this.adapter(opts.adapter || Adapter);
this.sockets = this.of("/");
this.opts = opts;
if (srv || typeof srv == "number") this.attach(srv as http.Server | number);
if (srv || typeof srv == "number") this.attach(srv as http.Server | https.Server | number);
}

/**
Expand Down Expand Up @@ -300,7 +301,7 @@ export class Server<
* @public
*/
public listen(
srv: http.Server | number,
srv: http.Server | https.Server | number,
opts: Partial<ServerOptions> = {}
): this {
return this.attach(srv, opts);
Expand All @@ -315,7 +316,7 @@ export class Server<
* @public
*/
public attach(
srv: http.Server | number,
srv: http.Server | https.Server | number,
opts: Partial<ServerOptions> = {}
): this {
if ("function" == typeof srv) {
Expand Down Expand Up @@ -421,7 +422,7 @@ export class Server<
* @private
*/
private initEngine(
srv: http.Server,
srv: http.Server | https.Server,
opts: EngineOptions & AttachOptions
): void {
// initialize engine
Expand All @@ -444,7 +445,7 @@ export class Server<
* @param srv http server
* @private
*/
private attachServe(srv: http.Server): void {
private attachServe(srv: http.Server | https.Server): void {
debug("attaching client serving req handler");

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