fix(types): make io#httpServer public (#5035)

Related: https://github.com/socketio/socket.io/issues/5034
This commit is contained in:
tnfAngel
2024-05-27 17:09:14 +01:00
committed by GitHub
parent 89c4c7eb47
commit 31f10f6808
2 changed files with 9 additions and 5 deletions

View File

@@ -169,6 +169,12 @@ export class Server<
*
*/
public engine: BaseServer;
/**
* The underlying Node.js HTTP server.
*
* @see https://nodejs.org/api/http.html
*/
public httpServer: TServerInstance;
/** @private */
readonly _parser: typeof parser;
@@ -209,7 +215,6 @@ export class Server<
* @private
*/
_connectTimeout: number;
private httpServer: TServerInstance;
private _corsMiddleware: (
req: http.IncomingMessage,
res: http.ServerResponse,

View File

@@ -7,6 +7,7 @@ import {
SocketOptions,
} from "socket.io-client";
import request from "supertest";
import type { AddressInfo } from "node:net";
import type { DefaultEventsMap, EventsMap } from "../../lib/typed-events";
const expect = require("expect.js");
@@ -40,8 +41,7 @@ export function createClient<
nsp: string = "/",
opts?: Partial<ManagerOptions & SocketOptions>
): ClientSocket<STC, CTS> {
// @ts-ignore
const port = io.httpServer.address().port;
const port = (io.httpServer.address() as AddressInfo).port;
return ioc(`http://localhost:${port}${nsp}`, opts);
}
@@ -74,8 +74,7 @@ export function assert(condition: any): asserts condition {
}
export function getPort(io: Server): number {
// @ts-ignore
return io.httpServer.address().port;
return (io.httpServer.address() as AddressInfo).port;
}
export function createPartialDone(count: number, done: (err?: Error) => void) {