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:
31
backend/src/routes/divisions.js
Normal file
31
backend/src/routes/divisions.js
Normal 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;
|
||||
Reference in New Issue
Block a user