// DSCM-X API Routes

import { Router } from 'express';
import { dscmNodeManagerService } from './dscm-node-manager.service';
import { computeDistributionService } from './compute-distribution.service';
import { federatedAiService } from './federated-ai.service';

const router = Router();

router.post('/nodes/register', async (req, res, next) => {
  try {
    const node = await dscmNodeManagerService.registerNode(req.body);
    res.status(201).json(node);
  } catch (error) {
      return next(error);
  }
});

router.post('/tasks/distribute', async (req, res, next) => {
  try {
    const task = await computeDistributionService.distributeTask(req.body);
    res.json(task);
  } catch (error) {
      return next(error);
  }
});

router.post('/federated-ai', async (req, res, next) => {
  try {
    const task = await federatedAiService.executeFederatedAiTask(req.body);
    res.json(task);
  } catch (error) {
      return next(error);
  }
});

export default router;

