diff --git a/backend/broker.js b/backend/broker.js
deleted file mode 100644
index 3c3b807..0000000
--- a/backend/broker.js
+++ /dev/null
@@ -1,131 +0,0 @@
-import { exec } from 'child_process';
-import * as fs from 'fs';
-var config;
-const nodemailer = require('nodemailer');
-export function executeCommand() {
- exec('iching divine', (error, stdout, stderr) => {
- console.log(`Begin`);
- 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(`Send E-Mail`);
- 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');
- return JSON.parse(data);
-}
-// Send E-Mail
-async function sendEmail(content) {
- // Create Transporter
- const transporter = nodemailer.createTransport({
- host: config.mailHost,
- port: 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; // + "
"; TODO: try without this
- }
- else {
- currentNode.value = currentNode.value + line + "
";
- }
- }
- return root;
-}
-// Generate HTML from Parse Tree
-function render(node) {
- if (node == undefined) {
- console.log("Rendering of nodes finished!");
- return "";
- }
- console.log("Render node" + node.type);
- 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/backend/broker.mjs b/backend/broker.mjs deleted file mode 100644 index 3c3b807..0000000 --- a/backend/broker.mjs +++ /dev/null @@ -1,131 +0,0 @@ -import { exec } from 'child_process'; -import * as fs from 'fs'; -var config; -const nodemailer = require('nodemailer'); -export function executeCommand() { - exec('iching divine', (error, stdout, stderr) => { - console.log(`Begin`); - 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(`Send E-Mail`); - 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'); - return JSON.parse(data); -} -// Send E-Mail -async function sendEmail(content) { - // Create Transporter - const transporter = nodemailer.createTransport({ - host: config.mailHost, - port: config.mailPort, - secure: false - }); - try { - const info = await transporter.sendMail({ - from: '"The Oracle"" + node.value + "
" + node.value + "
" + node.value + "
"; - outputHTML = outputHTML + render(node.child); - return outputHTML; - } -} diff --git a/backend/broker.test.js b/backend/broker.test.js deleted file mode 100644 index 0ec4d2b..0000000 --- a/backend/broker.test.js +++ /dev/null @@ -1,21 +0,0 @@ -"use strict"; -/*import { html } from "./broker"; -import { test, beforeAll, afterAll } from "@jest/globals"; - -jest.useFakeTimers(); - -test("Generate HTML for hexagram", () => { - expect(html("Hexagram No. 45 ䷬\nGathering Together [Massing]\n萃 (cuì)")) - .toBe("