import bodyParser from 'body-parser';
import { ExpressAdapter } from '@bull-board/express';
import http from 'http';
-import { Server } from 'socket.io';
-import {HttpError} from '../errors';
+import { Server, Socket } from 'socket.io';
type AuthInfo = {
authInfo: {
}
}
+ getSocketFromAuthenticatedUser(authInfo: {token: string, accountId: string}): Socket | null {
+ let socket: Socket;
+
+ this.ws.of('/').sockets.forEach(s => {
+ const auth = this.authFromUrl(s.request.headers['referer']);
+ if (auth.authInfo.accountId === authInfo.accountId && auth.authInfo.token === authInfo.token) {
+ socket = s;
+ }
+ });
+
+ return socket;
+ }
+
wrap<I, O>(handler: HttpHandler<I, O>, hxEvents: string) {
const self = this;
return async function (req: Request, res: Response) {