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'); const { scopeEvent, campusIndependent } = require('../utils/campusScope'); // 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, campusIndependent('previews a certificate template from the request body'), previewCertificate); router.get('/certificates/:id/pdf', protect, downloadCertificate); router.post('/certificates/:id/revoke', protect, supervisor, scopeEvent({ resolve: 'certificate' }), revokeCertificate); // Attendance register router.get('/:eventId', protect, staff, scopeEvent(), getRegister); router.get('/:eventId/export', protect, staff, scopeEvent(), exportRegister); router.post('/:eventId/mark', protect, supervisor, scopeEvent(), markAttendance); router.post('/:eventId/certificates', protect, supervisor, scopeEvent(), issueCertificates); router.post('/:eventId/certificates/send', protect, supervisor, scopeEvent(), sendCertificatesHandler); router.get('/:eventId/certificates.pdf', protect, supervisor, scopeEvent(), downloadEventCertificates); module.exports = router;