update nice visuel

This commit is contained in:
gpatruno
2026-07-25 20:04:34 +02:00
parent 3a8871cbae
commit 810e4ac922
78 changed files with 6742 additions and 3116 deletions
+41 -6
View File
@@ -1,7 +1,9 @@
import { Router } from 'express';
import { requireAuth } from '../middleware.js';
import {
getJackpotState,
listJackpotBattles,
getJackpotRound,
createJackpotBattle,
placeJackpotBet,
withdrawJackpotBet,
} from '../services/jackpot.js';
@@ -16,25 +18,58 @@ function handleError(res, err) {
router.get('/', async (_req, res) => {
try {
const state = await getJackpotState();
res.json({ round: state });
const battles = await listJackpotBattles();
res.json({ battles });
} catch (err) {
handleError(res, err);
}
});
router.get('/:id', async (req, res) => {
try {
const round = await getJackpotRound(req.params.id);
if (!round) {
return res.status(404).json({ error: 'Battle not found' });
}
res.json({ round });
} catch (err) {
handleError(res, err);
}
});
/** Create a battle by placing the first bet (no round id). */
router.post('/bet', requireAuth, async (req, res) => {
try {
const state = await placeJackpotBet(req.session.userId, req.body.inventoryItemIds);
const state = await createJackpotBattle(
req.session.userId,
req.body.inventoryItemIds
);
res.json({ round: state });
} catch (err) {
handleError(res, err);
}
});
router.post('/withdraw', requireAuth, async (req, res) => {
router.post('/:id/bet', requireAuth, async (req, res) => {
try {
const state = await withdrawJackpotBet(req.session.userId, req.body.inventoryItemIds);
const state = await placeJackpotBet(
req.params.id,
req.session.userId,
req.body.inventoryItemIds
);
res.json({ round: state });
} catch (err) {
handleError(res, err);
}
});
router.post('/:id/withdraw', requireAuth, async (req, res) => {
try {
const state = await withdrawJackpotBet(
req.params.id,
req.session.userId,
req.body.inventoryItemIds
);
res.json({ round: state });
} catch (err) {
handleError(res, err);