const express = require('express'); const router = express.Router(); const { getRegister, markAttendance, exportRegister, issueCertificates, revokeCertificate, sendCertificatesHandler, downloadEventCertificates, previewCertificate, myCertificates, downloadCertificate, verifyCertificate, } = require('../controllers/attendanceController'); const { protect, staff, supervisor } = require('../middleware/authMiddleware'); // Certificates — fixed paths first so they aren't taken as an :eventId router.get('/certificates/verify/:code', verifyCertificate); router.get('/certificates/mine', protect, myCertificates); router.post('/certificates/preview', protect, supervisor, previewCertificate); router.get('/certificates/:id/pdf', protect, downloadCertificate); router.post('/certificates/:id/revoke', protect, supervisor, revokeCertificate); // Attendance register router.get('/:eventId', protect, staff, getRegister); router.get('/:eventId/export', protect, staff, exportRegister); router.post('/:eventId/mark', protect, supervisor, markAttendance); router.post('/:eventId/certificates', protect, supervisor, issueCertificates); router.post('/:eventId/certificates/send', protect, supervisor, sendCertificatesHandler); router.get('/:eventId/certificates.pdf', protect, supervisor, downloadEventCertificates); module.exports = router;