feat: add api passthough notification to socket

This commit is contained in:
Methapon2001 2025-09-02 15:48:40 +07:00
parent c999b9cec7
commit 12a6186fc4

View file

@ -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 || [],
},
);
}
}