Fix P2 issues

This commit is contained in:
jason
2026-03-27 13:42:35 -05:00
parent 3eac74f28c
commit 308a4c5641
6 changed files with 544 additions and 87 deletions

View File

@@ -1,5 +1,6 @@
import { Router } from 'express';
import * as connService from '../services/connectionService';
import { ok } from '../types/index';
const router = Router();
@@ -8,7 +9,7 @@ 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);
res.status(201).json(ok(conn));
} catch (err) {
next(err);
}
@@ -19,7 +20,7 @@ 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);
res.json(ok(conn));
} catch (err) {
next(err);
}
@@ -29,7 +30,7 @@ router.put('/:id', async (req, res, next) => {
router.delete('/:id', async (req, res, next) => {
try {
await connService.deleteConnection(req.params.id);
res.json({ success: true });
res.json(ok(null));
} catch (err) {
next(err);
}
@@ -39,7 +40,7 @@ router.delete('/:id', async (req, res, next) => {
router.delete('/ports/:p1/:p2', async (req, res, next) => {
try {
await connService.deleteByPorts(req.params.p1, req.params.p2);
res.json({ success: true });
res.json(ok(null));
} catch (err) {
next(err);
}