From c17565ab24cbef05404d698de9890800002de7df Mon Sep 17 00:00:00 2001 From: Harvmaster Date: Mon, 3 Aug 2026 03:19:48 +0000 Subject: [PATCH] Add BAD_REQUEST status code --- source/services/transport/ws-transport.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/services/transport/ws-transport.ts b/source/services/transport/ws-transport.ts index 71a60f7..0f34bdd 100644 --- a/source/services/transport/ws-transport.ts +++ b/source/services/transport/ws-transport.ts @@ -7,11 +7,13 @@ import { toExtendedJson, fromExtendedJson } from '@xo-cash/utils'; import { z } from 'zod'; import type { Logger } from '../../utils/logger.ts'; -import { ApplicationError, normalizePublicError } from '../../errors/index.ts'; import type { ApplicationRequest, ApplicationRouter } from '../router.ts'; -import { WSStream } from '../stream/ws-stream.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'; + /** Default WebSocket upgrade path for application messages. */ const WS_ROUTE = '/ws'; @@ -198,7 +200,7 @@ export class WsTransportRouter implements UpgradeTransportRouter { try { decoded = fromExtendedJson(payload); } catch { - throw new ApplicationError(400, 'Invalid JSON in WebSocket message'); + throw new ApplicationError(HTTP_STATUS_CODE_BAD_REQUEST, 'Invalid JSON in WebSocket message'); } const envelope = wsRequestSchema.parse(decoded);