import { Router } from 'express'; import * as connService from '../services/connectionService'; const router = Router(); // POST /api/connections router.post('/', async (req, res, next) => { try { const { fromPortId, toPortId, color, label, edgeType } = req.body; const conn = await connService.createConnection({ fromPortId, toPortId, color, label, edgeType }); res.status(201).json(conn); } catch (err) { next(err); } }); // PUT /api/connections/:id router.put('/:id', async (req, res, next) => { try { const { color, label, edgeType } = req.body; const conn = await connService.updateConnection(req.params.id, { color, label, edgeType }); res.json(conn); } catch (err) { next(err); } }); // DELETE /api/connections/:id router.delete('/:id', async (req, res, next) => { try { await connService.deleteConnection(req.params.id); res.json({ success: true }); } catch (err) { next(err); } }); // DELETE /api/connections/ports/:p1/:p2 (remove link between two specific ports) router.delete('/ports/:p1/:p2', async (req, res, next) => { try { await connService.deleteByPorts(req.params.p1, req.params.p2); res.json({ success: true }); } catch (err) { next(err); } }); export default router;