const fs = require("fs"); const express = require("express"); const app = express(); const { exec } = require("child_process"); const nodeMailer = require("nodemailer"); // Read configuration file const contentFile = fs.readFileSync("./service_run/giteaService.conf", "utf8"); let checkStatus = "ready"; // Get port from configuration file const PORT = contentFile .split("\n") .find(line => line.includes("PORT_SERVICE")) ?.split("=")[1] .trim() || 5000; // Get email configuration from config file const getConfigValue = (key) => contentFile .split("\n") .find(line => line.includes(key)) ?.split("=")[1] .trim(); // Configure email transporter const createTransporter = () => nodeMailer.createTransport({ pool: true, host: "mail.apactech.io", port: 465, secure: true, auth: { user: "admin@apactech.io", pass: "BGK!dyt6upd2eax1bhz", }, }); app.use(express.json()); app.post("/git/gitea-webhook", async (req, res) => { let title = ""; const checkSendMail = getConfigValue("SEND_EMAIL"); const emailAddress = getConfigValue("EMAIL_ADDRESS"); const giteaEvent = req.headers["x-gitea-event"]; // Return response immediately res.status(200).send({ mess: "The event has been received!", data: req.body }); console.log("STATUS:", checkStatus); // Check if there is a running process if (checkStatus === "busy") { if (checkSendMail === "True") { const transporter = createTransporter(); const options = { from: "admin@apactech.io", to: emailAddress, subject: "Git notifications (Fail)", html: "