feat(tkuser): 알림 시스템 이관 system1-factory → tkuser
- 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>
This commit is contained in:
@@ -21,6 +21,8 @@ const partnerRoutes = require('./routes/partnerRoutes');
|
||||
const vendorRoutes = require('./routes/vendorRoutes');
|
||||
const consumableItemRoutes = require('./routes/consumableItemRoutes');
|
||||
const notificationRecipientRoutes = require('./routes/notificationRecipientRoutes');
|
||||
const notificationRoutes = require('./routes/notificationRoutes');
|
||||
const pushSubscriptionRoutes = require('./routes/pushSubscriptionRoutes');
|
||||
|
||||
const app = express();
|
||||
const PORT = process.env.PORT || 3000;
|
||||
@@ -31,6 +33,8 @@ const allowedOrigins = [
|
||||
'https://tkqc.technicalkorea.net',
|
||||
'https://tkuser.technicalkorea.net',
|
||||
'https://tkpurchase.technicalkorea.net',
|
||||
'https://tksafety.technicalkorea.net',
|
||||
'https://tksupport.technicalkorea.net',
|
||||
];
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
allowedOrigins.push('http://localhost:30080', 'http://localhost:30180', 'http://localhost:30280');
|
||||
@@ -64,6 +68,8 @@ app.use('/api/partners', partnerRoutes);
|
||||
app.use('/api/vendors', vendorRoutes);
|
||||
app.use('/api/consumable-items', consumableItemRoutes);
|
||||
app.use('/api/notification-recipients', notificationRecipientRoutes);
|
||||
app.use('/api/notifications', notificationRoutes);
|
||||
app.use('/api/push', pushSubscriptionRoutes);
|
||||
|
||||
// 404
|
||||
app.use((req, res) => {
|
||||
@@ -83,4 +89,21 @@ app.listen(PORT, () => {
|
||||
console.log(`tkuser-api running on port ${PORT}`);
|
||||
});
|
||||
|
||||
// 오래된 알림 정리 cron (매일 03:00 KST)
|
||||
(function scheduleNotificationCleanup() {
|
||||
const notificationModel = require('./models/notificationModel');
|
||||
function runCleanup() {
|
||||
const now = new Date();
|
||||
const kstHour = (now.getUTCHours() + 9) % 24;
|
||||
if (kstHour === 3 && now.getMinutes() < 1) {
|
||||
notificationModel.deleteOld(30).then(count => {
|
||||
if (count > 0) console.log(`오래된 알림 ${count}건 정리 완료`);
|
||||
}).catch(err => {
|
||||
console.error('알림 정리 실패:', err.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
setInterval(runCleanup, 60000);
|
||||
})();
|
||||
|
||||
module.exports = app;
|
||||
|
||||
Reference in New Issue
Block a user