Add manual trigger endpoints for scheduler service in sessionRoutes

Introduce new POST endpoints for triggering rating updates and fetching match results, along with a GET endpoint for retrieving scheduler status. Enhance error handling and response formatting for better API usability.
This commit is contained in:
Torsten Schulz (local)
2025-10-17 08:10:26 +02:00
parent c74217f6d8
commit 2dd5e28cbc

View File

@@ -1,9 +1,38 @@
import express from 'express';
import { authenticate } from '../middleware/authMiddleware.js';
import sessionController from '../controllers/sessionController.js';
import schedulerService from '../services/schedulerService.js';
const router = express.Router();
router.get('/status', authenticate, sessionController.checkSession);
// Manual trigger endpoints for testing
router.post('/trigger-rating-updates', authenticate, async (req, res) => {
try {
const result = await schedulerService.triggerRatingUpdates();
res.json(result);
} catch (error) {
res.status(500).json({ success: false, message: error.message });
}
});
router.post('/trigger-match-fetch', authenticate, async (req, res) => {
try {
const result = await schedulerService.triggerMatchResultsFetch();
res.json(result);
} catch (error) {
res.status(500).json({ success: false, message: error.message });
}
});
router.get('/scheduler-status', authenticate, (req, res) => {
const status = schedulerService.getStatus();
const nextRatingUpdate = schedulerService.getNextRatingUpdateTime();
res.json({
...status,
nextRatingUpdate
});
});
export default router;