"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.emailQueueRouter = void 0;
const express_1 = require("express");
const auth_middleware_1 = require("../../../middleware/auth.middleware");
const rbac_middleware_1 = require("../../../middleware/rbac.middleware");
const email_queue_service_1 = require("../../../services/email-queue.service");
const roles_1 = require("../../../utils/roles");
const router = (0, express_1.Router)();
exports.emailQueueRouter = router;
router.use(auth_middleware_1.authenticate);
router.use((0, rbac_middleware_1.requireRole)(...roles_1.INFLUENCE_ROLES));
// GET /api/email-queue/stats
router.get('/stats', async (_req, res, next) => {
    try {
        const stats = await email_queue_service_1.emailQueueService.getStats();
        res.json(stats);
    }
    catch (err) {
        next(err);
    }
});
// POST /api/email-queue/pause
router.post('/pause', async (_req, res, next) => {
    try {
        await email_queue_service_1.emailQueueService.pause();
        res.json({ message: 'Queue paused' });
    }
    catch (err) {
        next(err);
    }
});
// POST /api/email-queue/resume
router.post('/resume', async (_req, res, next) => {
    try {
        await email_queue_service_1.emailQueueService.resume();
        res.json({ message: 'Queue resumed' });
    }
    catch (err) {
        next(err);
    }
});
// POST /api/email-queue/clean
router.post('/clean', async (_req, res, next) => {
    try {
        const cleaned = await email_queue_service_1.emailQueueService.clean();
        res.json({ message: `Cleaned ${cleaned} completed jobs`, cleaned });
    }
    catch (err) {
        next(err);
    }
});
//# sourceMappingURL=email-queue.routes.js.map