import { Router } from 'express';
import { matchRunningGames } from '../services/game-matching.service';

const router = Router();

router.post('/match', async (req, res) => {
  try {
    const result = await matchRunningGames(req.body?.processes, req.body?.userId ?? req.ip);

    res.json(result);
  } catch (error) {
    console.error('[Games] Failed to match running games', error);
    res.status(500).json({ error: 'Failed to match running games' });
  }
});

export default router;
