Initial commit: Своя Игра - multiplayer quiz game

This commit is contained in:
Cosmo
2026-03-21 05:00:06 +00:00
commit 1d46ad8b06
80 changed files with 9215 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
import express from 'express';
import { nanoid } from 'nanoid';
const router = express.Router();
// Создать новую игру
router.post('/create', (req, res) => {
try {
const gameCode = nanoid(6).toUpperCase();
const { teamName } = req.body;
const game = {
gameCode,
teams: [{
name: teamName,
score: 0,
players: []
}],
currentRound: 1,
usedQuestions: [],
status: 'waiting',
createdAt: new Date()
};
res.json({
success: true,
gameCode,
game
});
} catch (error) {
res.status(500).json({ error: error.message });
}
});
// Проверить существование игры
router.get('/:gameCode', (req, res) => {
try {
const { gameCode } = req.params;
// Проверка будет в Socket.io, т.к. игры хранятся в памяти
res.json({ exists: true });
} catch (error) {
res.status(500).json({ error: error.message });
}
});
export default router;