From 12a6186fc430b6b07af27b2a77ae5719d3f885e6 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Tue, 2 Sep 2025 15:48:40 +0700 Subject: [PATCH] feat: add api passthough notification to socket --- src/controllers/SocketController.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/controllers/SocketController.ts diff --git a/src/controllers/SocketController.ts b/src/controllers/SocketController.ts new file mode 100644 index 00000000..3b6f455b --- /dev/null +++ b/src/controllers/SocketController.ts @@ -0,0 +1,25 @@ +import { Body, Controller, Post, Route } from "tsoa"; +import { sendWebSocket } from "../services/webSocket"; + +@Route("/api/v1/through-socket") +export class SocketController extends Controller { + @Post("notify") + async notify( + @Body() + payload: { + message: string; + userId?: string | string[]; + roles?: string | string[]; + error?: boolean; + }, + ) { + sendWebSocket( + "socket-notification", + { success: !payload.error, message: payload.message }, + { + roles: payload.roles || [], + userId: payload.userId || [], + }, + ); + } +}