import express from 'express';
import {
  createTreelogy,
  listTreelogies,
  getTreelogyById,
  updateTreelogy,
  deleteTreelogy
} from '../controllers/treelogyController.js';
import { requireAuth, requireRole } from '../middleware/auth.js';

const router = express.Router();

// Public reads can stay as they are if you want. Writes need auth.
router.post('/', requireAuth, requireRole('SUPER_ADMIN', 'CLIENT_ADMIN'), createTreelogy);
router.get('/', requireAuth, listTreelogies);
router.get('/:id', requireAuth, getTreelogyById);
router.put('/:id', requireAuth, requireRole('SUPER_ADMIN', 'CLIENT_ADMIN'), updateTreelogy);
router.delete('/:id', requireAuth, requireRole('SUPER_ADMIN'), deleteTreelogy);

export default router;
