live updates
This commit is contained in:
@@ -4,10 +4,12 @@ import dotenv from 'dotenv';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { createServer } from 'http';
|
||||
import rateLimit from 'express-rate-limit';
|
||||
import { initDB } from './db/index.js';
|
||||
import { validateConfig, config } from './config.js';
|
||||
import { errorHandler } from './middleware/errorHandler.js';
|
||||
import { initializeSocket } from './sockets/index.js';
|
||||
import authRoutes from './routes/auth.js';
|
||||
import challengeRoutes from './routes/challenges.js';
|
||||
import predictionRoutes from './routes/predictions.js';
|
||||
@@ -24,6 +26,10 @@ const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const app = express();
|
||||
const httpServer = createServer(app);
|
||||
|
||||
// Initialize Socket.io
|
||||
initializeSocket(httpServer);
|
||||
|
||||
// Rate limiting
|
||||
const authLimiter = rateLimit({
|
||||
@@ -96,8 +102,9 @@ const PORT = config.server.port;
|
||||
// Initialize database and start server
|
||||
initDB()
|
||||
.then(() => {
|
||||
app.listen(PORT, '0.0.0.0', () => {
|
||||
httpServer.listen(PORT, '0.0.0.0', () => {
|
||||
console.log(`✅ Server running on port ${PORT}`);
|
||||
console.log(`🔌 Socket.io ready for real-time updates`);
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
|
||||
Reference in New Issue
Block a user