Events can take a waitlist for sold-out lines. When places free up (cancellation, smaller booking, higher stock limit) the next person is offered them with a claim link and the places are held for a set time; unclaimed offers expire and move on, with optional partial offers. Stock is now counted in one place (utils/stock.js), including held places, and manual registrations and booking edits are now stock-checked. Adds a supervisor waitlist page, My Events waitlists, and the daily summary count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
1.0 KiB
JavaScript
20 lines
1.0 KiB
JavaScript
const express = require('express');
|
|
const rateLimit = require('express-rate-limit');
|
|
const router = express.Router();
|
|
const { joinWaitlist, myWaitlist, leaveWaitlist, claimInfo, eventWaitlist, offerManually, moveEntry, removeEntry } = require('../controllers/waitlistController');
|
|
const { protect, staff, supervisor, optionalAuth } = require('../middleware/authMiddleware');
|
|
|
|
// Claim links are credentials, so keep guessing slow.
|
|
const claimLimiter = rateLimit({ windowMs: 60 * 1000, max: 30, message: { message: 'Too many attempts. Please try again in a minute.' } });
|
|
|
|
router.post('/', optionalAuth, joinWaitlist);
|
|
router.get('/mine', protect, myWaitlist);
|
|
router.get('/claim/:token', claimLimiter, claimInfo);
|
|
router.get('/events/:eventId', protect, staff, eventWaitlist);
|
|
router.post('/:id/offer', protect, supervisor, offerManually);
|
|
router.post('/:id/move', protect, supervisor, moveEntry);
|
|
router.post('/:id/remove', protect, supervisor, removeEntry);
|
|
router.delete('/:id', protect, leaveWaitlist);
|
|
|
|
module.exports = router;
|