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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user