feat: add api passthough notification to socket
This commit is contained in:
parent
c999b9cec7
commit
12a6186fc4
1 changed files with 25 additions and 0 deletions
25
src/controllers/SocketController.ts
Normal file
25
src/controllers/SocketController.ts
Normal 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 || [],
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue