const express = require('express');
const router = express.Router();
const listmonkController = require('../controllers/listmonkController');
const { requireAuth, requireAdmin } = require('../middleware/auth');

// Get sync status (available to all authenticated users)
router.get('/status', requireAuth, listmonkController.getSyncStatus);

// Test connection (admin only)
router.get('/test-connection', requireAdmin, listmonkController.testConnection);

// Get list statistics (admin only)
router.get('/stats', requireAdmin, listmonkController.getListStats);

// Bulk sync operations (admin only)
router.post('/sync/locations', requireAdmin, listmonkController.syncAllLocations);

router.post('/sync/users', requireAdmin, listmonkController.syncAllUsers);

router.post('/sync/all', requireAdmin, listmonkController.syncAll);

// Reinitialize lists (admin only)
router.post('/reinitialize', requireAdmin, listmonkController.reinitializeLists);

module.exports = router;
