💿 Created a socket mixin

This commit is contained in:
2021-12-02 16:12:54 -08:00
parent fdd6538a96
commit 2c16de674f
3 changed files with 17 additions and 15 deletions

View File

@@ -1,5 +1,16 @@
import { Server } from "socket.io";
import { createServer } from "http";
export const SocketIOMixin = () => {
const socketServer = createServer();
socketServer.listen(3001, `0.0.0.0`);
const socketIOConnection = new Server(socketServer, {
cors: {
origin: "*",
methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
preflightContinue: false,
optionsSuccessStatus: 204,
},
});
return socketIOConnection;
}