diff --git a/packages/express-keepalive-ws/bun.lockb b/packages/express-keepalive-ws/bun.lockb index fcd346b..21fcf7d 100755 Binary files a/packages/express-keepalive-ws/bun.lockb and b/packages/express-keepalive-ws/bun.lockb differ diff --git a/packages/keepalive-ws/src/server/index.ts b/packages/keepalive-ws/src/server/index.ts index c4a37c9..b939a6b 100644 --- a/packages/keepalive-ws/src/server/index.ts +++ b/packages/keepalive-ws/src/server/index.ts @@ -130,7 +130,9 @@ export type KeepAliveServerOptions = ServerOptions & { export class KeepAliveServer extends WebSocketServer { connections: { [id: string]: Connection } = {}; remoteAddressToConnections: { [address: string]: Connection[] } = {}; - commands: { [command: string]: (context: WSContext) => Promise } = {}; + commands: { + [command: string]: (context: WSContext) => Promise | any; + } = {}; globalMiddlewares: SocketMiddleware[] = []; middlewares: { [key: string]: SocketMiddleware[] } = {}; rooms: { [roomName: string]: Set } = {}; @@ -330,9 +332,9 @@ export class KeepAliveServer extends WebSocketServer { this.rooms[roomName] = new Set(); } - registerCommand( + registerCommand( command: string, - callback: SocketMiddleware, + callback: (context: WSContext) => Promise | T, middlewares: SocketMiddleware[] = [], ) { this.commands[command] = callback;