Skip to content

Commit 132d05f

Browse files
fix(sio): expose type of default engine
Related: #4693
1 parent d5095fe commit 132d05f

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

packages/engine.io/lib/server.ts

+3
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,9 @@ class WebSocketResponse {
662662
}
663663
}
664664

665+
/**
666+
* An Engine.IO server based on Node.js built-in HTTP server and the `ws` package for WebSocket connections.
667+
*/
665668
export class Server extends BaseServer {
666669
public httpServer?: HttpServer;
667670
private ws: any;

packages/engine.io/lib/userver.ts

+4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export interface uOptions {
2323
maxBackpressure?: number;
2424
}
2525

26+
/**
27+
* An Engine.IO server based on the `uWebSockets.js` package.
28+
*/
29+
// TODO export it into its own package
2630
export class uServer extends BaseServer {
2731
protected init() {}
2832
protected cleanup() {}

packages/socket.io/lib/index.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ import accepts = require("accepts");
77
import { pipeline } from "stream";
88
import path = require("path");
99
import { attach, Server as Engine, uServer } from "engine.io";
10-
import type {
11-
ServerOptions as EngineOptions,
12-
AttachOptions,
13-
BaseServer,
14-
} from "engine.io";
10+
import type { ServerOptions as EngineOptions, AttachOptions } from "engine.io";
1511
import { Client } from "./client";
1612
import { EventEmitter } from "events";
1713
import { ExtendedError, Namespace, ServerReservedEventsMap } from "./namespace";
@@ -228,7 +224,7 @@ export class Server<
228224
* const clientsCount = io.engine.clientsCount;
229225
*
230226
*/
231-
public engine: BaseServer;
227+
public engine: Engine;
232228
/**
233229
* The underlying Node.js HTTP server.
234230
*
@@ -712,7 +708,9 @@ export class Server<
712708
* @param engine engine.io (or compatible) server
713709
* @return self
714710
*/
715-
public bind(engine: BaseServer): this {
711+
public bind(engine: any): this {
712+
// TODO apply strict types to the engine: "connection" event, `close()` and a method to serve static content
713+
// this would allow to provide any custom engine, like one based on Deno or Bun built-in HTTP server
716714
this.engine = engine;
717715
this.engine.on("connection", this.onconnection.bind(this));
718716
return this;

0 commit comments

Comments
 (0)