mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 19:59:20 +00:00
17 lines
380 B
TypeScript
17 lines
380 B
TypeScript
import socketIo, { Server as SocketIO } from "socket.io";
|
|
import { Server } from "http";
|
|
import AppError from "../errors/AppError";
|
|
|
|
let io: SocketIO;
|
|
|
|
export const initIO = (httpServer: Server): SocketIO => {
|
|
io = socketIo(httpServer);
|
|
return io;
|
|
};
|
|
export const getIO = (): SocketIO => {
|
|
if (!io) {
|
|
throw new AppError("Socket IO not initialized");
|
|
}
|
|
return io;
|
|
};
|