/**
 * Routes newsletter
 */
import { Router } from 'express';
import * as newsletterController from '../controllers/newsletter.controller.js';
import { authenticateToken, authorizeRoles } from '../middleware/auth.js';
import { validate } from '../middleware/validate.js';
import { subscribeSchema, unsubscribeSchema } from '../validations/newsletter.validation.js';

const router = Router();

// Routes publiques
router.post('/subscribe', validate(subscribeSchema), newsletterController.subscribe);
router.post('/unsubscribe', validate(unsubscribeSchema), newsletterController.unsubscribe);

// Routes protégées (Admin seulement)
router.get(
  '/subscribers',
  authenticateToken,
  authorizeRoles('ADMIN'),
  newsletterController.getSubscribers
);

router.get(
  '/count',
  authenticateToken,
  authorizeRoles('ADMIN'),
  newsletterController.getActiveCount
);

export default router;
