import { Router } from 'express';
import * as projectController from '../controllers/projectController.js';
import { extractUser, requireAdmin } from '../middleware/authMiddleware.js';

const router = Router();

// Rotas com contexto de usuário (leitura)
router.get('/', extractUser, projectController.getAllProjects);
router.get('/dashboard', extractUser, projectController.getDashboardProjects);
router.get('/:id', extractUser, projectController.getProjectById);

// Protected routes (require admin permission)
router.post('/', extractUser, requireAdmin, projectController.createProject);
router.put('/:id', extractUser, requireAdmin, projectController.updateProject);
router.delete('/:id', extractUser, requireAdmin, projectController.deleteProject);
router.patch('/:id/archive', extractUser, requireAdmin, projectController.archiveProject);

export default router;
