const express = require('express');
const adminConfigController = require('../controllers/adminConfigController');
const { authenticateAdmin } = require('../middleware/auth');
const { requireAdmin } = require('../middleware/rbac');

const router = express.Router();

/**
 * Admin Config Routes
 * All routes require admin authentication
 */

// Apply authentication middleware
router.use(authenticateAdmin);

/**
 * @route   GET /api/v1/admin/config
 * @desc    Get all configurations
 * @access  Private (Admin)
 */
router.get('/', requireAdmin, adminConfigController.getAllConfigs);

/**
 * @route   GET /api/v1/admin/config/:key
 * @desc    Get configuration by key
 * @access  Private (Admin)
 */
router.get('/:key', requireAdmin, adminConfigController.getConfig);

/**
 * @route   PUT /api/v1/admin/config/:key
 * @desc    Update configuration
 * @access  Private (Admin)
 */
router.put('/:key', requireAdmin, adminConfigController.updateConfig);

/**
 * @route   DELETE /api/v1/admin/config/:key
 * @desc    Delete configuration
 * @access  Private (Admin)
 */
router.delete('/:key', requireAdmin, adminConfigController.deleteConfig);

module.exports = router;
