require('dotenv').config(); const http = require('http'); const { Server } = require('socket.io'); const { createApp } = require('./app'); const { attachSockets } = require('./sockets'); const PORT = process.env.PORT || 4000; const app = createApp(); const server = http.createServer(app); const io = new Server(server, { cors: { origin: process.env.CORS_ORIGIN || 'http://localhost:5173' }, }); attachSockets(io); app.set('io', io); server.listen(PORT, () => { console.log(`D&D Campaign Manager API listening on http://localhost:${PORT}`); });