// src/routes/index.js
const express = require('express');
const router = express.Router();
const cors = require('cors');
const config = require('../config');

// Importe toutes les routes modulaires
const projectRoutes = require('./projectRoutes');
const measurementRoutes = require('./measurementRoutes');
const videoRoutes = require('./videoRoutes');
const imageRoutes = require('./imageRoutes');
const cameraRoutes = require('./cameraRoutes');

// Configuration CORS
router.use(cors({
  origin: config.server.cors.origins,
  methods: config.server.cors.methods,
  allowedHeaders: config.server.cors.allowedHeaders,
  credentials: config.server.cors.credentials
}));

// Enregistre toutes les routes
router.use(projectRoutes);
router.use(measurementRoutes);
router.use(videoRoutes);
router.use(imageRoutes);
router.use(cameraRoutes);

// Route de test/santé de l'API
router.get('/health', (req, res) => {
  res.json({ status: 'ok', uptime: process.uptime() });
});

module.exports = router;