import { Router } from 'express';
import settingsController from '../controllers/settings.controller';
import { authenticate } from '../middleware/auth.middleware';
import { requirePermission } from '../middleware/rbac.middleware';

const router = Router();
const auth = [authenticate, requirePermission('admin:write')] as const;

router.get('/', ...auth, settingsController.getAll.bind(settingsController));
router.get('/preferences', authenticate, settingsController.getUserPreferences.bind(settingsController));
router.put('/preferences', authenticate, settingsController.updateUserPreferences.bind(settingsController));
router.get('/:key', ...auth, settingsController.get.bind(settingsController));
router.put('/:key', ...auth, settingsController.update.bind(settingsController));

export default router;
