/**
 * @swagger
 * tags:
 *   name: SolaceNet Fees
 *   description: Fees and pricing engine
 */

import { Router } from 'express';
import { zeroTrustAuthMiddleware } from '@/integration/api-gateway/middleware/auth.middleware';
import { feesService, CalculateFeeRequest } from './fees.service';

const router = Router();

/**
 * @swagger
 * /api/v1/solacenet/fees/calculate:
 *   post:
 *     summary: Calculate fees
 *     tags: [SolaceNet Fees]
 *     security:
 *       - SovereignToken: []
 */
router.post('/calculate', zeroTrustAuthMiddleware, async (req, res, next) => {
  try {
    const request = req.body as CalculateFeeRequest;
    const calculation = await feesService.calculateFee(request);
    res.json(calculation);
  } catch (error) {
    next(error);
  }
});

export default router;
