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