diff --git a/README.md b/README.md
index ae36927..9de1b6b 100644
--- a/README.md
+++ b/README.md
@@ -11,10 +11,9 @@ This app will send an I-Ching horoscope to the pre-configured mailhog instance i
This app uses the I-Ching library app https://github.com/Velfi/i-ching.git.
-
-
+It is also possible to configure the intervall of days between the sending of horoscopes and the time of sending. The default is to send one email every seven days at 8 am.
This will start the deployment of the app in the pod, the service and an ingress for the HTTP frontend server and an ingress for the backend server.
When a pod with the app is initally started, one email will be sent to the configured receiver.
@@ -64,5 +63,3 @@ The app can be deployed by running:
$ kubectl apply -f deployment.yaml
```
Der HTTP-Server can be access in a browser with the address https://192-168-197-2.c-one-infra.de/iching/
-
-
\ No newline at end of file
diff --git a/dist/backend/broker.js b/dist/backend/broker.js
deleted file mode 100644
index 3977cc9..0000000
--- a/dist/backend/broker.js
+++ /dev/null
@@ -1,137 +0,0 @@
-import { exec } from 'child_process';
-import * as fs from 'fs';
-import * as nodemailer from 'nodemailer';
-import { fileURLToPath } from 'url';
-import * as path from 'path';
-var config;
-export function executeCommand() {
- exec('iching divine', (error, stdout, stderr) => {
- console.log(`I-Ching-Broker: \'iching divine\' called`);
- if (error) {
- console.error(`Error: ${error.message}`);
- return;
- }
- if (stderr) {
- console.error(`Stderr: ${stderr}`);
- return;
- }
- //Load config once
- if (config == undefined) {
- config = loadConfig();
- }
- console.log(`Horoscope received; sending E-Mail next`);
- sendEmail(stdout);
- });
-}
-// Run function once initially, called from Dockerfile
-executeCommand();
-// Load the Configuration
-function loadConfig() {
- console.log(`Load Config`);
- //const data = fs.readFileSync('config.json', 'utf-8');
- //const configPath = path.join(__dirname, 'config.json');
- const __filename = fileURLToPath(import.meta.url);
- const __dirname = path.dirname(__filename);
- const configPath = path.join(__dirname, 'config.json');
- const data = fs.readFileSync(configPath, 'utf-8');
- return JSON.parse(data);
-}
-// Send E-Mail
-async function sendEmail(content) {
- // Create Transporter
- const transporter = nodemailer.createTransport({
- host: config.mailHost, //"mailhog.mailhog.svc.cluster.local", //config.mailHost,
- port: config.mailPort, //1025, //config.mailPort,
- secure: false
- });
- try {
- const info = await transporter.sendMail({
- from: '"The Oracle" " + node.value + " " + node.value + "" + line + "
";
- }
- else if (line.startsWith("Judgement")) {
- const judgement = { type: "Judgement" };
- currentNode.child = judgement;
- currentNode = judgement;
- currentNode.value = "" + line + "
";
- }
- else if (line.startsWith("Images")) {
- const images = { type: "Images" };
- currentNode.child = images;
- currentNode = images;
- currentNode.value = "" + line + "
";
- }
- else if (line.startsWith("~") && currentNode.type != "ChangingLines") {
- const changingLines = { type: "ChangingLines" };
- currentNode.child = changingLines;
- currentNode = changingLines;
- currentNode.value = line;
- }
- else {
- currentNode.value = currentNode.value + line + "
";
- }
- }
- return root;
-}
-// Generate HTML from Parse Tree
-function render(node) {
- if (node == undefined) {
- console.log("I-Ching-Broker: Rendering of nodes finished!");
- return "";
- }
- var outputHTML = "";
- switch (node.type) {
- case "Root":
- return render(node.child);
- case "Hexagram":
- node.value = node.value?.replace("", "
");
- node.value = node.value?.replace("
", "");
- node.value = node.value?.replace("
", " - ");
- outputHTML = "
" + node.value + "
"; - outputHTML = outputHTML + render(node.child); - return outputHTML; - } -} diff --git a/dist/backend/config.json b/dist/backend/config.json deleted file mode 100644 index 121311d..0000000 --- a/dist/backend/config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "emailReceiver": "test@mailhog.local", - "mailHost": "mailhog.mailhog.svc.cluster.local", - "mailPort": 1025 -} \ No newline at end of file diff --git a/dist/backend/server.js b/dist/backend/server.js deleted file mode 100644 index b0f87f6..0000000 --- a/dist/backend/server.js +++ /dev/null @@ -1,15 +0,0 @@ -import express from 'express'; -import cors from 'cors'; -import { executeCommand } from './broker.js'; -const app = express(); -const port = 8090; -app.use(cors()); -app.post('/iching/api/command', (req, res) => { - //TODO no logging from inside this method??? - console.log(`Backend-Server: receiving POST to /iching/api/command`); - executeCommand(); - res.status(200).send('Backend-Server: Broker was called\n'); -}); -app.listen(port, '0.0.0.0', () => { - console.log(`Backend-Server running on http://0.0.0.0:${port}`); -}); diff --git a/dist/frontend/deploy.js b/dist/frontend/deploy.js deleted file mode 100644 index 402c906..0000000 --- a/dist/frontend/deploy.js +++ /dev/null @@ -1 +0,0 @@ -window.DEPLOY_MODE = 'local'; diff --git a/dist/frontend/event.mjs b/dist/frontend/event.mjs deleted file mode 100644 index c0fa2db..0000000 --- a/dist/frontend/event.mjs +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -function handleClick() { - console.log("Der Button wurde geklickt!"); - //const deployMode = (window as { DEPLOY_MODE?: 'docker' | 'k8s' }).DEPLOY_MODE ?? 'k8s'; - const deployMode = window.DEPLOY_MODE ?? 'k8s'; - const endpoint = deployMode === 'docker' || deployMode === 'local' - ? 'http://localhost:8090/iching/api/command' - : '/iching/api/command'; - console.log(`DEPLOY_MODE=${deployMode}, sende POST an: ${endpoint}`); - fetch(endpoint, { method: 'POST' }) - .then(res => res.text()) - .then(text => console.log("HTTP-Server says:", text)) - .catch(error => console.error("HTTP-Server - Error:", error)); -} -document.addEventListener("DOMContentLoaded", () => { - const button = document.getElementById("myButton"); - button?.addEventListener("click", handleClick); -}); diff --git a/dist/frontend/index.html b/dist/frontend/index.html deleted file mode 100644 index 9c6984a..0000000 --- a/dist/frontend/index.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - -Click on the Button to receive your personal Horoscope. 100% accuracy guaranteed!
- - -