// CASO API Routes

import { Router } from 'express';
import { casoOptimizerService } from './caso-optimizer.service';
import { casoRoutingService } from './caso-routing.service';

const router = Router();

/**
 * @swagger
 * /api/v1/caso/optimize:
 *   post:
 *     summary: Optimize settlement route
 */
router.post('/optimize', async (req, res, next) => {
  try {
    const result = await casoOptimizerService.optimizeRoute(req.body);
    res.json(result);
  } catch (error) {
      return next(error);
  }
});

/**
 * @swagger
 * /api/v1/caso/route:
 *   post:
 *     summary: Calculate and apply route
 */
router.post('/route', async (req, res, next) => {
  try {
    const result = await casoRoutingService.calculateAndApplyRoute(req.body);
    res.json(result);
  } catch (error) {
      return next(error);
  }
});

export default router;

