import { Router } from 'express';
import { getTrafficRules } from '../services/unifiClient.js';

const router = Router();

router.get('/', async (req, res) => {
  try {
    const rules = await getTrafficRules();
    const list = Array.isArray(rules) ? rules : rules?.data || [];
    res.json(list);
  } catch (err) {
    res.status(500).json({ error: err.message });
  }
});

export default router;
