rps-royale/apps/server/src/server.ts
Ubuntu 64e8fb6c49 Initial commit: monorepo structure, smart contract, server, and Phaser frontend
Phase 0 foundation:
- Docker Compose with PostgreSQL, Redis, Hardhat node
- RPSArena.sol commit-reveal smart contract with tests
- Node.js + Socket.io server with matchmaking and match state machine
- Next.js + Phaser 3 frontend with Boot, Lobby, Arena, Result scenes
- Nginx Proxy Manager integration planned for jeu.cosmolan.fr

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 02:14:42 +00:00

25 lines
767 B
TypeScript

import express from 'express';
import { createServer as createHttpServer } from 'http';
import { Server } from 'socket.io';
import cors from 'cors';
import { setupSocketHandlers } from './socket/handlers.js';
import { apiRoutes } from './api/routes.js';
export function createServer(port: number | string) {
const app = express();
app.use(cors({ origin: process.env.CORS_ORIGIN || '*' }));
app.use(express.json());
app.use('/api', apiRoutes);
const httpServer = createHttpServer(app);
const io = new Server(httpServer, {
cors: { origin: process.env.CORS_ORIGIN || '*' },
transports: ['websocket', 'polling'],
});
setupSocketHandlers(io);
httpServer.listen(port, () => {
console.log(`[RPS Server] Listening on port ${port}`);
});
}