From 173c444c627d79b5d7006b3cf2f50e1187d70fa3 Mon Sep 17 00:00:00 2001 From: Christopher Hase Date: Mon, 14 Apr 2025 10:01:35 +0200 Subject: [PATCH] add http-server part 8.1 --- backend/broker.ts | 2 +- frontend/event.ts | 16 +++++++--------- ingress.yaml | 14 ++++++++++++-- old.ingress.yaml | 24 ++++++++++++++++++++++++ old.service.yaml | 13 +++++++++++++ service.yaml | 6 ++++-- 6 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 old.ingress.yaml create mode 100644 old.service.yaml diff --git a/backend/broker.ts b/backend/broker.ts index 99b0845..ab96233 100644 --- a/backend/broker.ts +++ b/backend/broker.ts @@ -77,7 +77,7 @@ async function sendEmail(content: string) { html: html(content) }); - console.log("E-Mail sent: ", info.messageId); + console.log("E-Mail sent: ", info.messageId + "\n"); } catch (error) { console.error("Error Sending E-Mail:", error); } diff --git a/frontend/event.ts b/frontend/event.ts index b1a0b12..6bf6399 100644 --- a/frontend/event.ts +++ b/frontend/event.ts @@ -2,16 +2,10 @@ function handleClick(): void { console.log("Der Button wurde geklickt!"); alert("Hallo von TypeScript!"); + + //fetch("http://192-168-197-2.c-one-infra.de:8090/api/command", { method: "POST" }) - //fetch("http://localhost:8090/api/command", { - //fetch("/api/command", { - fetch("http://192-168-197-2.c-one-infra.de:8090/api/command", { - method: "POST" - /*, - headers: { - "Content-Type": "application/json", // Füge dies hinzu, wenn du JSON sendest - }*/ - }) + fetch("/iching/api/command", { method: "POST" }) .then(res => res.text()) .then(text => console.log("Server sagt:", text)) .catch(error => console.error("Fehler:", error)); @@ -22,6 +16,10 @@ document.addEventListener("DOMContentLoaded", () => { button?.addEventListener("click", handleClick); }); + + //fetch("http://localhost:8090/api/command", { + //fetch("/api/command", { + /*fetch("/api/command", { method: "POST" }) .then(res => res.text()) .then(text => console.log("Server sagt:", text));*/ diff --git a/ingress.yaml b/ingress.yaml index 9482165..770129e 100644 --- a/ingress.yaml +++ b/ingress.yaml @@ -11,8 +11,15 @@ spec: - host: 192-168-197-2.c-one-infra.de http: paths: + - path: /iching/api(/|$)(.*) + pathType: ImplementationSpecific + backend: + service: + name: iching-service + port: + number: 81 - path: /iching(/|$)(.*) - pathType: ImplementationSpecific + pathType: ImplementationSpecific backend: service: name: iching-service @@ -21,4 +28,7 @@ spec: tls: - hosts: - 192-168-197-2.c-one-infra.de - secretName: argocd-net-tls \ No newline at end of file + secretName: argocd-net-tls + + + diff --git a/old.ingress.yaml b/old.ingress.yaml new file mode 100644 index 0000000..9482165 --- /dev/null +++ b/old.ingress.yaml @@ -0,0 +1,24 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: iching-ingress + namespace: argocd + annotations: + nginx.ingress.kubernetes.io/rewrite-target: /$2 +spec: + ingressClassName: nginx + rules: + - host: 192-168-197-2.c-one-infra.de + http: + paths: + - path: /iching(/|$)(.*) + pathType: ImplementationSpecific + backend: + service: + name: iching-service + port: + number: 80 + tls: + - hosts: + - 192-168-197-2.c-one-infra.de + secretName: argocd-net-tls \ No newline at end of file diff --git a/old.service.yaml b/old.service.yaml new file mode 100644 index 0000000..2b810e0 --- /dev/null +++ b/old.service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: iching-service + namespace: argocd +spec: + selector: + app: iching-broker + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + type: ClusterIP \ No newline at end of file diff --git a/service.yaml b/service.yaml index 2b810e0..db42575 100644 --- a/service.yaml +++ b/service.yaml @@ -7,7 +7,9 @@ spec: selector: app: iching-broker ports: - - protocol: TCP + - name: frontend port: 80 targetPort: 8080 - type: ClusterIP \ No newline at end of file + - name: backend + port: 81 + targetPort: 8090 \ No newline at end of file