diff --git a/backend/routes/analyticsRoutes.js b/backend/routes/analyticsRoutes.js index d87ee07..79fe0c5 100644 --- a/backend/routes/analyticsRoutes.js +++ b/backend/routes/analyticsRoutes.js @@ -20,37 +20,6 @@ router.get("/breakdown", getBreakdown); router.get('/model-drift', checkModelDrift); router.get("/me", getPersonalSummary); -router.get('/trends', protect, async (req, res) => { - try { - const { days = 7 } = req.query; - const userId = req.user.id; - - const predictions = await History.find({ - user: userId, - createdAt: { $gte: new Date(Date.now() - days * 24 * 60 * 60 * 1000) } - }); - - const trends = {}; - predictions.forEach(p => { - const date = p.createdAt.toISOString().split('T')[0]; - if (!trends[date]) trends[date] = { total: 0, spam: 0 }; - trends[date].total++; - if (p.prediction === 'spam' || p.prediction === 'smishing') trends[date].spam++; - }); - - const result = Object.entries(trends).map(([date, d]) => ({ - date, - total: d.total, - spam: d.spam - })); - - res.json(result); - } catch (error) { - console.error('Trends error:', error); - res.status(500).json({ error: 'Failed to fetch trends' }); - } -}); - router.get("/breakdown", getBreakdown); router.get('/model-drift', checkModelDrift); router.get("/me", getPersonalSummary); diff --git a/backend/server.js b/backend/server.js index 6d8f300..3764ead 100644 --- a/backend/server.js +++ b/backend/server.js @@ -286,7 +286,7 @@ app.use('/admin/queues', adminAuth, serverAdapter.getRouter()); app.use("/", predictionRoutes); app.use("/", emailIntegrationRoutes); -app.use("/", imapRoutes); +app.use("/imap", imapRoutes); app.use("/", utilityRoutes); // Mounted after predictionRoutes so predictionRoutes' existing POST /bulk-predict // handler keeps precedence; this only newly exposes GET /bulk-predict/template. diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 08897db..96a0898 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -40,4 +40,60 @@ server { proxy_set_header X-Real-IP $remote_addr; proxy_cache_bypass $http_upgrade; } + + location /gmail { + proxy_pass http://node-backend:3000/gmail; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_cache_bypass $http_upgrade; + } + + location /outlook { + proxy_pass http://node-backend:3000/outlook; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_cache_bypass $http_upgrade; + } + + location /scan-emails { + proxy_pass http://node-backend:3000/scan-emails; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_cache_bypass $http_upgrade; + } + + location /analyze-email-header { + proxy_pass http://node-backend:3000/analyze-email-header; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_cache_bypass $http_upgrade; + } + + location /bulk-predict { + proxy_pass http://node-backend:3000/bulk-predict; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_cache_bypass $http_upgrade; + } + + location /spam-insights { + proxy_pass http://node-backend:3000/spam-insights; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_cache_bypass $http_upgrade; + } + + location /imap { + proxy_pass http://node-backend:3000/imap; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_cache_bypass $http_upgrade; + } }