ff-admin-server/src/middleware/checkSocketExists.ts

12 lines
404 B
TypeScript
Raw Normal View History

2025-07-15 11:52:58 +02:00
import { Event, Socket } from "socket.io";
import UnauthorizedRequestException from "../exceptions/unauthorizedRequestException";
import { SocketMap } from "../storage/socketMap";
export default async (socket: Socket, [event, ...args]: Event, next: any) => {
if (SocketMap.exists(socket.id)) {
next();
} else {
next(new UnauthorizedRequestException("not authorized for connection"));
}
};