// routes/notificationRecipientRoutes.js const express = require('express'); const router = express.Router(); const controller = require('../controllers/notificationRecipientController'); const { requireAuth, requireAdminOrPermission } = require('../middleware/auth'); // 모든 라우트에 인증 필요 router.use(requireAuth); // 알림 유형 목록 router.get('/types', controller.getTypes); // 전체 수신자 목록 (유형별 그룹화) router.get('/', controller.getAll); // ntfy 구독 관리 (/:type보다 위에 배치해야 "ntfy"를 type으로 잡지 않음) router.get('/ntfy', controller.getNtfySubscribers); router.post('/ntfy/:userId', controller.addNtfySubscription); router.delete('/ntfy/:userId', controller.removeNtfySubscription); // 유형별 수신자 조회 router.get('/:type', controller.getByType); // 수신자 추가 (본인: 모든 사용자, 타인: 관리자만 — 컨트롤러에서 검증) router.post('/', controller.add); // 유형별 수신자 일괄 설정 (관리자만) router.put('/:type', requireAdminOrPermission('tkuser.notification_recipients'), controller.setRecipients); // 수신자 제거 (본인: 모든 사용자, 타인: 관리자만 — 컨트롤러에서 검증) router.delete('/:type/:userId', controller.remove); module.exports = router;