feat: add competition heats system backend

- Add 3 new database tables: divisions, competition_types, event_user_heats
- Add seed data for 6 divisions (NEW, NOV, INT, ADV, ALL, CHA) and 2 competition types (J&J, STR)
- Add API endpoints for divisions and competition types
- Add heats management endpoints in events route (POST/GET/DELETE)
- Implement unique constraint: cannot have same role in same division+competition type
- Add participant verification before allowing heats management
- Support heat numbers 1-9 with optional Leader/Follower role
This commit is contained in:
Radosław Gierwiało
2025-11-14 15:32:40 +01:00
parent 0e5dc34cbf
commit 02d3d7ac42
7 changed files with 584 additions and 8 deletions

View File

@@ -0,0 +1,31 @@
const express = require('express');
const { prisma } = require('../utils/db');
const router = express.Router();
// GET /api/divisions - List all divisions (public)
router.get('/', async (req, res, next) => {
try {
const divisions = await prisma.division.findMany({
orderBy: {
displayOrder: 'asc',
},
select: {
id: true,
name: true,
abbreviation: true,
displayOrder: true,
},
});
res.json({
success: true,
count: divisions.length,
data: divisions,
});
} catch (error) {
next(error);
}
});
module.exports = router;