migrated socket IO initialization to typescript

This commit is contained in:
canove
2020-09-20 10:45:49 -03:00
parent 04750df172
commit b7484afd63
5 changed files with 48 additions and 30 deletions

View File

@@ -0,0 +1,15 @@
import socketIo, { Server as SocketIO } from "socket.io";
import { Server } from "http";
let io: SocketIO;
export const initIO = (httpServer: Server): SocketIO => {
io = socketIo(httpServer);
return io;
};
export const getIO = (): SocketIO => {
if (!io) {
throw new Error("Socket IO not initialized");
}
return io;
};