Canvas: Fix TCP gateway exposing DB
Change-Id: I0aef6a4754b0b674820d479b85fc770987164b02
diff --git a/apps/canvas/front/src/components/node-gateway-tcp.tsx b/apps/canvas/front/src/components/node-gateway-tcp.tsx
index bd1e5b6..c37f31b 100644
--- a/apps/canvas/front/src/components/node-gateway-tcp.tsx
+++ b/apps/canvas/front/src/components/node-gateway-tcp.tsx
@@ -209,15 +209,29 @@
});
store.setEdges(
edges.concat(
- exp.map(
- (e): Edge => ({
- id: uuidv4(),
- source: e.serviceId,
- sourceHandle: "ports",
- target: id,
- targetHandle: "tcp",
- }),
- ),
+ exp.map((e): Edge => {
+ const sn = nodes.find((n) => n.id === e.serviceId);
+ if (sn == null) {
+ throw new Error(`Service ${e.serviceId} not found`);
+ }
+ if (sn.type === "app") {
+ return {
+ id: uuidv4(),
+ source: e.serviceId,
+ sourceHandle: "ports",
+ target: id,
+ targetHandle: "tcp",
+ };
+ } else {
+ return {
+ id: uuidv4(),
+ source: e.serviceId,
+ sourceHandle: "env_var",
+ target: id,
+ targetHandle: "tcp",
+ };
+ }
+ }),
),
);
},