- Phase 1: tkuser에 알림 CRUD, Push/ntfy 발송, 내부 알림 API 추가 - Phase 2: notifyHelper URL을 tkuser-api:3000으로 전환 (system2, tkpurchase, tksafety, system1) - Phase 3: notification-bell.js API 도메인 tkuser로 변경 + 캐시 버스팅 v=4 - Phase 4: system1에서 알림 코드 제거 (routes, controllers, models, utils) 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('../middleware/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;
|