const express = require("express");
const { Server } = require("socket.io");
const http = require("http");
const app = express();
const path = require("path");

app.use(express.static(path.join(__dirname, './dist')));

app.get('*', (req, res) => res.sendFile(path.join(__dirname, './dist', 'index.html')));

app.disable("x-powered-by");

const server = http.createServer(app);
const io = new Server(server, {cors: {origin: "*"}});

// Pass io to the connection handler
io.on("connection", require("./handler/connection")(io));

server.listen(5287, () => {
    console.log("Server running on port 5287");
});