// Unified Pan-Reality Monetary Fabric (UPRMF) API Routes

import { Router } from 'express';
import { uprmfService } from './uprmf.service';

const router = Router();

/**
 * @swagger
 * /api/v1/uprmf/merge:
 *   post:
 *     summary: Merge monetary fabric
 */
router.post('/merge', async (req, res, next) => {
  try {
    const result = await uprmfService.mergeFabric(req.body);
    res.json(result);
  } catch (error) {
      return next(error);
  }
});

/**
 * @swagger
 * /api/v1/uprmf/state:
 *   get:
 *     summary: Get current fabric state
 */
router.get('/state', async (req, res, next) => {
  try {
    const result = await uprmfService.getFabricState();
    if (!result) {
      return res.status(404).json({ error: 'No fabric state found' });
    }
    res.json(result);
  } catch (error) {
      return next(error);
  }
});

/**
 * @swagger
 * /api/v1/uprmf/alignments/:alignmentType/correct:
 *   post:
 *     summary: Correct alignment issue
 */
router.post('/alignments/:alignmentType/correct', async (req, res, next) => {
  try {
    const result = await uprmfService.correctAlignment(req.params.alignmentType);
    res.json(result);
  } catch (error) {
      return next(error);
  }
});

export default router;

