Many fixes
This commit is contained in:
@@ -8,11 +8,11 @@ import { z } from 'zod';
|
||||
|
||||
import type { Logger } from '../../utils/logger.ts';
|
||||
import type { ApplicationRequest, ApplicationRouter } from '../router.ts';
|
||||
import type { AppEnv, UpgradeTransportRouter } from './transport-router.ts';
|
||||
|
||||
import { ApplicationError, normalizePublicError } from '../../errors/index.ts';
|
||||
import { HTTP_STATUS_CODE_BAD_REQUEST } from '../../constants.ts';
|
||||
import { WSStream } from '../stream/ws-stream.ts';
|
||||
import { type AppEnv, BaseTransport } from './base-transport.ts';
|
||||
|
||||
/** Default WebSocket upgrade path for application messages. */
|
||||
const WS_ROUTE = '/ws';
|
||||
@@ -33,7 +33,7 @@ const wsRequestSchema = z
|
||||
* One WSStream is shared by every message on a socket, allowing subscribe and
|
||||
* unsubscribe requests to operate on the same broadcaster registration.
|
||||
*/
|
||||
export class WsTransportRouter implements UpgradeTransportRouter {
|
||||
export class WsTransportRouter extends BaseTransport {
|
||||
/**
|
||||
* Native Node WebSocket server used by Hono's Node adapter.
|
||||
*
|
||||
@@ -42,9 +42,6 @@ export class WsTransportRouter implements UpgradeTransportRouter {
|
||||
*/
|
||||
private readonly wsServer: WebSocketServer;
|
||||
|
||||
/** Upgrade server wired into the Node HTTP listener by ServerHost. */
|
||||
readonly websocketServer: WebSocketServerLike;
|
||||
|
||||
private readonly debug: Logger;
|
||||
|
||||
/**
|
||||
@@ -59,6 +56,8 @@ export class WsTransportRouter implements UpgradeTransportRouter {
|
||||
private readonly maxRequestBodyBytes: number,
|
||||
private readonly url: string = WS_ROUTE,
|
||||
) {
|
||||
super();
|
||||
|
||||
this.debug = debug.extend('ws-transport');
|
||||
|
||||
// Hono's Node WebSocket helper delegates frame handling to `ws`; unlike
|
||||
@@ -68,7 +67,6 @@ export class WsTransportRouter implements UpgradeTransportRouter {
|
||||
noServer: true,
|
||||
maxPayload: this.maxRequestBodyBytes,
|
||||
});
|
||||
this.websocketServer = this.wsServer as unknown as WebSocketServerLike;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user