require("dotenv").config(); const express = require("express"); const cors = require("cors"); const app = express(); const http = require("http").Server(app); const initializeWebSocket = require("./websocket"); // TODO redis store const io = require("socket.io")(http, { cors: { origin: "http://localhost:5173", methods: ["GET", "POST"], }, }); initializeWebSocket(io); app.use(cors({ credentials: false, origin: "http://localhost:5173" })); app.use(express.json()); app.use((req, _, next) => { req.io = io; next(); }); app.get("/", (req, res) => res.send("worked")) const PORT = process.env.PORT || 3002; http.listen(PORT, () => { console.log(`Server listening at http://localhost:${PORT}`); });