initialize project structure with essential files and configurations from ToneGuessr

This commit is contained in:
2025-04-24 11:13:29 +02:00
parent 569e390a89
commit e818af6900
20 changed files with 5273 additions and 0 deletions

35
server/index.js Normal file
View File

@ -0,0 +1,35 @@
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.disable("x-powered-by");
app.get('*', (req, res) => res.sendFile(path.join(__dirname, './dist', 'index.html')));
const server = http.createServer(app);
const io = new Server(server, {
cors: {origin: "*"},
pingTimeout: 30000,
pingInterval: 10000
});
server.on('error', (error) => {
console.error('Server error:', error);
});
const PORT = process.env.PORT || 5237;
server.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
process.on('SIGINT', () => {
console.log('Server shutting down...');
server.close(() => {
console.log('Server closed');
process.exit(0);
});
});