From fa246b2fa8514541aaa47e79b44e7092a960e112 Mon Sep 17 00:00:00 2001 From: Christopher Hase Date: Mon, 31 Mar 2025 11:06:14 +0200 Subject: [PATCH] more config part 4 --- README.md | 17 +++++++++++++++++ broker.ts | 20 +++++++++++++------- config.json | 4 +++- 3 files changed, 33 insertions(+), 8 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b1e6534 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# I-Ching + +The I-Ching (a.k.a. the *Book of Changes*) is an ancient method of divination based on +cleromancy (assigning meaning to the generation of apparently random numbers.) Six numbers +between 6 and 9 are generated in order to create a hexagram, the meaning of which is +contained in the I Ching book. + +You can find lots of great information on the 2000+ year history of the I-Ching on +[Wikipedia](https://en.wikipedia.org/wiki/I_Ching) + +This app will send an I-Ching horoscope to the pre-configured mailhog instance in configurable intervalls. + +This app uses the I-Ching library app https://github.com/Velfi/i-ching.git. + +## Configuration +It is possible to configure the intervall of days between the sending of horoscopes and the time of sending. + diff --git a/broker.ts b/broker.ts index ead3e38..785e31d 100644 --- a/broker.ts +++ b/broker.ts @@ -6,6 +6,8 @@ interface Config { daysInterval: number; timeOfDay: string; emailReceiver: string; + mailHost: string; + mailPort: number; } // Node structure for the Parse Tree (it's a degenerated tree with one or zero children per node) @@ -19,13 +21,6 @@ var config : Config; const nodemailer = require('nodemailer'); -// Create Transporter -const transporter = nodemailer.createTransport({ - host: "mailhog.mailhog.svc.cluster.local", // MailHog ClusterIP - port: 1025, // Standard-MailHog SMTP-Port - secure: false // MailHog needs no encryption -}); - function executeCommand(): void { exec('iching divine', (error, stdout, stderr) => { @@ -73,6 +68,17 @@ function loadConfig(): Config { // Send E-Mail async function sendEmail(content: string) { + + // Create Transporter + const transporter = nodemailer.createTransport({ + //host: "mailhog.mailhog.svc.cluster.local", // MailHog ClusterIP + host: config.mailHost, + //port: 1025, // Standard-MailHog SMTP-Port + port: config.mailPort, + secure: false // MailHog needs no encryption + }); + + try { const info = await transporter.sendMail({ from: '"The Oracle" ', diff --git a/config.json b/config.json index 3523d07..60134d4 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,7 @@ { "daysInterval": 2, "timeOfDay": "8:00", - "emailReceiver": "test@mailhog.local" + "emailReceiver": "test@mailhog.local", + "mailHost": "mailhog.mailhog.svc.cluster.local", + "mailPort": 1025 } \ No newline at end of file