- Phase 1: 모든 서비스 헤더에 알림 벨 UI 추가 (notification-bell.js) - Phase 2: VAPID Web Push 구독/전송 (push-sw.js, pushSubscription API) - Phase 3: 내부 알림 API + notifyHelper로 서비스간 알림 연동 - tksafety: 출입 승인/반려, 안전교육 완료, 방문자 체크인 - tkpurchase: 일용공 신청, 작업보고서 제출 - system2-report: 신고 접수/확인/처리완료 - Phase 4: 30일 이상 알림 자동 정리 cron, Redis 캐싱 - CORS에 tkuser/tkpurchase/tksafety 서브도메인 추가 - HTML cache busting 버전 갱신 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
// routes/notificationRoutes.js
|
|
const express = require('express');
|
|
const router = express.Router();
|
|
const notificationController = require('../controllers/notificationController');
|
|
const { requireAuth, requireMinLevel } = require('../middlewares/auth');
|
|
|
|
// 내부 서비스용 알림 생성 (X-Internal-Service-Key 인증, JWT 불필요)
|
|
router.post('/internal', notificationController.createInternal);
|
|
|
|
// 이하 모든 라우트는 JWT 인증 필요
|
|
router.use(requireAuth);
|
|
|
|
// 읽지 않은 알림 조회 (본인 알림만)
|
|
router.get('/unread', notificationController.getUnread);
|
|
|
|
// 읽지 않은 알림 개수
|
|
router.get('/unread/count', notificationController.getUnreadCount);
|
|
|
|
// 전체 알림 조회 (페이징)
|
|
router.get('/', notificationController.getAll);
|
|
|
|
// 알림 생성 (시스템/관리자용)
|
|
router.post('/', requireMinLevel('support_team'), notificationController.create);
|
|
|
|
// 모든 알림 읽음 처리 (본인 알림만)
|
|
router.post('/read-all', notificationController.markAllAsRead);
|
|
|
|
// 특정 알림 읽음 처리 (본인 알림만)
|
|
router.post('/:id/read', notificationController.markAsRead);
|
|
|
|
// 알림 삭제 (본인 알림만)
|
|
router.delete('/:id', notificationController.delete);
|
|
|
|
module.exports = router;
|