commit 489de02f49b970da47999365083aa476bc049d91 Author: Manesh Date: Sun Apr 5 10:49:05 2026 +0000 Clean repo: removed node_modules and added gitignore diff --git a/.env b/.env new file mode 100755 index 0000000..d2b309f --- /dev/null +++ b/.env @@ -0,0 +1 @@ +SSL_MANAGER_URL="https://api.hestiacp.metatronhost.com" \ No newline at end of file diff --git a/BAK/SSL_CRON copy 2.js b/BAK/SSL_CRON copy 2.js new file mode 100755 index 0000000..fe788a8 --- /dev/null +++ b/BAK/SSL_CRON copy 2.js @@ -0,0 +1,125 @@ +// sslCron.mjs + +import cron from "node-cron"; +import axios from "axios"; + +// Base URL of your SSL manager Express API +// e.g. the server where you defined /dns/domains and /ssl/refresh +const API_BASE = + process.env.SSL_MANAGER_URL || "https://api.hestiacp.metatronhost.com"; + +/** + * Parse "notAfter" like: "Mar 11 19:08:24 2026 GMT" + */ +function parseNotAfter(notAfterStr) { + if (!notAfterStr) return null; + const d = new Date(notAfterStr); // JS can parse this format directly + if (isNaN(d.getTime())) return null; + return d; +} + +/** + * Return days left until SSL expiry from notAfter. + * If invalid โ†’ return large negative number. + */ +function daysLeftFromSsl(notAfterStr) { + const expiry = parseNotAfter(notAfterStr); + if (!expiry) return -9999; + + const now = new Date(); + const diffMs = expiry.getTime() - now.getTime(); + const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)); + return diffDays; +} + +/** + * Decide if SSL is expired based on notAfter + */ +function isSslExpired(notAfterStr) { + const expiry = parseNotAfter(notAfterStr); + if (!expiry) return true; // if we can't parse it, treat as expired + const now = new Date(); + return now > expiry; +} + +/** + * One cycle: + * - Fetch domain list (/dns/domains) + * - For each domain, look at ssl.notAfter + * - If expired -> (for now) just console.log the renew call + */ +async function checkAndRenewOnce() { + try { + console.log("๐Ÿ” [SSL CRON] Fetching domains..."); + const res = await axios.get(`${API_BASE}/dns/domains`); + + if (!res.data?.success) { + console.error("โŒ [SSL CRON] /dns/domains failed:", res.data); + return; + } + + const rawParsed = res.data.rawParsed || []; + console.log(`๐Ÿ“ฆ [SSL CRON] Found ${rawParsed.length} DNS entries`); + + for (const row of rawParsed) { + const { domain, ssl } = row; + + const notAfter = ssl?.notAfter || null; + const left = daysLeftFromSsl(notAfter); + const expired = isSslExpired(notAfter); + + console.log( + `๐ŸŒ Domain: ${domain} | notAfter: ${notAfter} | daysLeft: ${left} | expired: ${expired}` + ); + + if (!expired) { + continue; // SSL still valid, skip + } + + // ๐Ÿ” For now: only log what we *would* do + console.log( + `๐Ÿ” [SSL CRON] Would renew SSL for ${domain} via POST ${API_BASE}/ssl/refresh` + ); + + // When you're ready to actually renew, uncomment this block: + /* + try { + console.log(`๐Ÿ” [SSL CRON] Renewing SSL for ${domain}...`); + const refreshRes = await axios.post(`${API_BASE}/ssl/refresh`, { + domain, + }); + + if (refreshRes.data?.success) { + console.log(`โœ… [SSL CRON] SSL renewed for ${domain}`); + } else { + console.error( + `โš ๏ธ [SSL CRON] Failed to renew ${domain}:`, + refreshRes.data + ); + } + } catch (err) { + console.error( + `โŒ [SSL CRON] Error renewing ${domain}:`, + err.response?.data || err.message + ); + } + */ + } + + console.log("๐ŸŽฏ [SSL CRON] Cycle completed."); + } catch (err) { + console.error( + "โŒ [SSL CRON] Error fetching domains:", + err.response?.data || err.message + ); + } +} + +// ๐Ÿ” Schedule to run once per day at 03:00 server time +cron.schedule("0 3 * * *", () => { + console.log("โฐ [SSL CRON] Daily job started..."); + checkAndRenewOnce(); +}); + +// Optional: run immediately when starting the script +checkAndRenewOnce(); diff --git a/BAK/SSL_CRON copy.js b/BAK/SSL_CRON copy.js new file mode 100755 index 0000000..2ffa10c --- /dev/null +++ b/BAK/SSL_CRON copy.js @@ -0,0 +1,117 @@ +// sslCron.mjs + +import cron from "node-cron"; +import axios from "axios"; + +// Base URL of your SSL manager Express API +// e.g. the server where you defined /dns/domains and /ssl/refresh +const API_BASE = process.env.SSL_MANAGER_URL || "https://api.hestiacp.metatronhost.com"; + +// How many days total you treat the cert as valid +// You said: "add the 89 days to the ssl date" โ†’ 1 (start) + 89 = 90 days +const CERT_LIFETIME_DAYS = 90; + +/** + * Given the "date" from rawParsed (e.g. "2025-06-27"), + * calculate expiry date (date + 89 days) and compare with now. + */ +function isExpired(dateStr) { + if (!dateStr) return true; + + const issued = new Date(dateStr + "T00:00:00Z"); // force UTC-ish + if (isNaN(issued.getTime())) return true; + + const expiry = new Date(issued); + expiry.setDate(expiry.getDate() + (CERT_LIFETIME_DAYS - 1)); // +89 days + + const now = new Date(); + return now > expiry; +} + +/** + * Optional helper: return days left until expiry (can be useful for logging/threshholds) + */ +function daysLeft(dateStr) { + const issued = new Date(dateStr + "T00:00:00Z"); + if (isNaN(issued.getTime())) return -9999; + + const expiry = new Date(issued); + expiry.setDate(expiry.getDate() + (CERT_LIFETIME_DAYS - 1)); + + const diffMs = expiry.getTime() - new Date().getTime(); + const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)); + return diffDays; +} + +/** + * This runs one cycle: + * - Fetch domain list + * - For each domain, decide if expired + * - If expired, call /ssl/refresh + */ +async function checkAndRenewOnce() { + try { + console.log("๐Ÿ” [SSL CRON] Fetching domains..."); + const res = await axios.get(`${API_BASE}/dns/domains`); + + if (!res.data?.success) { + console.error("โŒ [SSL CRON] /dns/domains failed:", res.data); + return; + } + + const rawParsed = res.data.rawParsed || []; + console.log(`๐Ÿ“ฆ [SSL CRON] Found ${rawParsed.length} DNS entries`); + + for (const row of rawParsed) { + const { domain, date } = row; + + const left = daysLeft(date); + const expired = isExpired(date); + + console.log( + `๐ŸŒ Domain: ${domain} | date: ${date} | daysLeft: ${left} | expired: ${expired}` + ); + + if (!expired) { + continue; // still valid, skip + } + + try { + console.log(`๐Ÿ” [SSL CRON] Renewing SSL for ${domain}...`); + const refreshRes = await axios.post(`${API_BASE}/ssl/refresh`, { + domain, + }); + + if (refreshRes.data?.success) { + console.log(`โœ… [SSL CRON] SSL renewed for ${domain}`); + } else { + console.error( + `โš ๏ธ [SSL CRON] Failed to renew ${domain}:`, + refreshRes.data + ); + } + } catch (err) { + console.error( + `โŒ [SSL CRON] Error renewing ${domain}:`, + err.response?.data || err.message + ); + } + } + + console.log("๐ŸŽฏ [SSL CRON] Cycle completed."); + } catch (err) { + console.error( + "โŒ [SSL CRON] Error fetching domains:", + err.response?.data || err.message + ); + } +} + +// ๐Ÿ” Schedule to run once per day at 03:00 server time +cron.schedule("0 3 * * *", () => { + console.log("โฐ [SSL CRON] Daily job started..."); + checkAndRenewOnce(); +}); + +// Optional: run immediately when starting the script +checkAndRenewOnce(); diff --git a/BAK/index copy 2.js b/BAK/index copy 2.js new file mode 100755 index 0000000..0fa22a9 --- /dev/null +++ b/BAK/index copy 2.js @@ -0,0 +1,361 @@ +// server.mjs (or server.js with "type": "module") + +import express from "express"; +import axios from "axios"; +import https from "https"; +import NodeCache from "node-cache"; + +// ๐Ÿ‘‰ Environment / Secrets +const API = process.env.HESTIA_API_HASH || "vvQjauyYQ2YDY2Au-_DC4QO5MUPFiHNn"; +const SERVER = + process.env.HESTIA_SERVER_URL || "https://host.metatronhost.com:8083/api/"; + +// ๐Ÿ‘‰ FIXED Hestia username +const HESTIA_USER = "user"; + +// ๐Ÿง  SSL info cache (per domain, 1 day TTL) +const sslCache = new NodeCache({ + stdTTL: 60 * 60 * 24, // 24 hours + checkperiod: 60 * 60, // check every hour +}); + +// Ignore self-signed SSL +const httpsAgent = new https.Agent({ + rejectUnauthorized: false, +}); + +// =============================== +// ๐Ÿ”ง H E S T I A H E L P E R S +// =============================== + +async function hestia(cmd, args = {}) { + const form = new URLSearchParams({ + hash: API, + cmd, + ...args, + }); + + const res = await axios.post(SERVER, form, { httpsAgent }); + return res.data; +} + +// Fetch raw DNS domain table +async function getRawDomainList() { + const form = new URLSearchParams({ + hash: API, + cmd: "v-list-dns-domains", + arg1: HESTIA_USER, + }); + + const res = await axios.post(SERVER, form, { httpsAgent }); + return res.data; +} + +// Parse domains from raw table (only domain names) +function parseDomainsFromTable(text) { + const lines = text.split("\n"); + const domains = []; + + for (let line of lines) { + line = line.trim(); + if (!line.includes(".")) continue; + if (line.startsWith("DOMAIN")) continue; + if (line.startsWith("------")) continue; + + const parts = line.split(/\s+/); + const domain = parts[0]; + + if (domain && domain.includes(".")) { + domains.push(domain); + } + } + + return domains; +} + +// Parse the full DNS table into structured rows +function parseRawTable(text) { + const lines = text.split("\n").map((l) => l.trim()).filter(Boolean); + + const dataRows = []; + + // Skip first 2 header lines + for (let i = 2; i < lines.length; i++) { + const line = lines[i]; + const parts = line.split(/\s+/); + + // Expect at least 8 columns + if (parts.length < 8) continue; + + const [domain, ip, tpl, ttl, dnssec, rec, spnd, date] = parts; + + dataRows.push({ + domain, + ip, + tpl, + ttl: Number(ttl), + dnssec, + rec: Number(rec), + spnd, + date, + }); + } + + return dataRows; +} + +// Remove SSL certificate +async function removeSsl(domain) { + return hestia("v-delete-web-domain-ssl", { + arg1: HESTIA_USER, + arg2: domain, + }); +} + +// Add Let's Encrypt SSL +async function addSsl(domain) { + return hestia("v-add-letsencrypt-domain", { + arg1: HESTIA_USER, + arg2: domain, + }); +} + +// Remove + Add (renew) +async function refreshSsl(domain) { + const removed = await removeSsl(domain); + const added = await addSsl(domain); + return { removed, added }; +} + +// โœ… Get REAL SSL info for a web domain, but return ONLY summary (no big CRT/KEY/CA) +async function getWebSslInfoSummary(domain) { + try { + // v-list-web-domain-ssl USER DOMAIN [FORMAT] + const data = await hestia("v-list-web-domain-ssl", { + arg1: HESTIA_USER, + arg2: domain, + arg3: "json", + }); + + let parsed = data; + + // If Hestia returns a string, try parse it + if (typeof data === "string") { + try { + parsed = JSON.parse(data); + } catch { + // if it fails, we just keep raw string, but there's no safe way to summarize + return { + success: true, + subject: null, + aliases: null, + notBefore: null, + notAfter: null, + issuer: null, + signature: null, + pubKey: null, + sslForce: null, + rawType: "string", + }; + } + } + + // parsed usually looks like: + // { "metatronhost.com": { CRT, KEY, CA, SUBJECT, ALIASES, NOT_BEFORE, NOT_AFTER, ... } } + const keys = Object.keys(parsed || {}); + if (!keys.length) { + return { + success: false, + error: "No SSL data found in response", + }; + } + + const cert = parsed[keys[0]] || {}; + + return { + success: true, + subject: cert.SUBJECT || null, + aliases: cert.ALIASES || null, + notBefore: cert.NOT_BEFORE || null, + notAfter: cert.NOT_AFTER || null, + issuer: cert.ISSUER || null, + signature: cert.SIGNATURE || null, + pubKey: cert.PUB_KEY || null, + sslForce: cert.SSL_FORCE || null, + }; + } catch (err) { + return { + success: false, + error: err.response?.data || err.message || "Unknown error", + }; + } +} + +// =============================== +// ๐Ÿš€ E X P R E S S A P I +// =============================== + +const app = express(); +app.use(express.json()); + +// Health +app.get("/", (req, res) => { + res.json({ running: true, user: HESTIA_USER }); +}); + +// Get all DNS domains + SSL summary (cached) +app.get("/dns/domains", async (req, res) => { + try { + const raw = await getRawDomainList(); + + const domains = parseDomainsFromTable(raw); + const rawParsed = parseRawTable(raw); + + const sslInfoByDomain = {}; + + for (const domain of domains) { + const cacheKey = `ssl-${domain}`; + let summary = sslCache.get(cacheKey); + + if (!summary) { + // Not in cache โ†’ fetch from Hestia and cache it + summary = await getWebSslInfoSummary(domain); + sslCache.set(cacheKey, summary); + } + + sslInfoByDomain[domain] = summary; + } + + const rawParsedWithSsl = rawParsed.map((row) => ({ + ...row, + ssl: sslInfoByDomain[row.domain] || null, + })); + + res.json({ + success: true, + domains, + rawParsed: rawParsedWithSsl, + }); + } catch (err) { + res.status(500).json({ + success: false, + error: err.response?.data || err.message, + }); + } +}); + +// Remove SSL +app.post("/ssl/remove", async (req, res) => { + const { domain } = req.body; + + if (!domain) { + return res + .status(400) + .json({ success: false, error: "domain is required" }); + } + + try { + const result = await removeSsl(domain); + // Invalidate cache for that domain, since SSL changed + sslCache.del(`ssl-${domain}`); + + res.json({ success: true, domain, result }); + } catch (err) { + res.status(500).json({ + success: false, + domain, + error: err.response?.data || err.message, + }); + } +}); + +// Add SSL +app.post("/ssl/add", async (req, res) => { + const { domain } = req.body; + + if (!domain) { + return res + .status(400) + .json({ success: false, error: "domain is required" }); + } + + try { + const result = await addSsl(domain); + // Invalidate cache so next /dns/domains pulls fresh SSL info + sslCache.del(`ssl-${domain}`); + + res.json({ success: true, domain, result }); + } catch (err) { + res.status(500).json({ + success: false, + domain, + error: err.response?.data || err.message, + }); + } +}); + +// Refresh SSL +app.post("/ssl/refresh", async (req, res) => { + const { domain } = req.body; + + if (!domain) { + return res + .status(400) + .json({ success: false, error: "domain is required" }); + } + + try { + const result = await refreshSsl(domain); + // Invalidate cache so next /dns/domains pulls fresh SSL info + sslCache.del(`ssl-${domain}`); + + res.json({ success: true, domain, result }); + } catch (err) { + res.status(500).json({ + success: false, + domain, + error: err.response?.data || err.message, + }); + } +}); + +// Refresh SSL for ALL domains +app.post("/ssl/refresh-all", async (req, res) => { + try { + const raw = await getRawDomainList(); + const domains = parseDomainsFromTable(raw); + + const results = []; + + for (const domain of domains) { + try { + const result = await refreshSsl(domain); + sslCache.del(`ssl-${domain}`); + results.push({ domain, success: true, result }); + } catch (e) { + results.push({ + domain, + success: false, + error: e.response?.data || e.message, + }); + } + } + + res.json({ + success: true, + user: HESTIA_USER, + results, + }); + } catch (err) { + res.status(500).json({ + success: false, + error: err.response?.data || err.message, + }); + } +}); + +// Start server +const PORT = process.env.PORT || 3015; +app.listen(PORT, () => { + console.log(`๐Ÿ”ฅ SSL Manager API running at port ${PORT}`); +}); diff --git a/BAK/index copy.js b/BAK/index copy.js new file mode 100755 index 0000000..79b68c6 --- /dev/null +++ b/BAK/index copy.js @@ -0,0 +1,265 @@ +// server.mjs (or server.js with "type": "module") + +import express from "express"; +import axios from "axios"; +import https from "https"; + +// ๐Ÿ‘‰ Environment / Secrets +const API = process.env.HESTIA_API_HASH || "vvQjauyYQ2YDY2Au-_DC4QO5MUPFiHNn"; +const SERVER = process.env.HESTIA_SERVER_URL || "https://host.metatronhost.com:8083/api/"; + +// ๐Ÿ‘‰ FIXED Hestia username +const HESTIA_USER = "user"; + +// Ignore self-signed SSL +const httpsAgent = new https.Agent({ + rejectUnauthorized: false, +}); + +// =============================== +// ๐Ÿ”ง H E S T I A H E L P E R S +// =============================== + +async function hestia(cmd, args = {}) { + const form = new URLSearchParams({ + hash: API, + cmd, + ...args, + }); + + const res = await axios.post(SERVER, form, { httpsAgent }); + return res.data; +} + +// Fetch raw DNS domain table +async function getRawDomainList() { + const form = new URLSearchParams({ + hash: API, + cmd: "v-list-dns-domains", + arg1: HESTIA_USER, + }); + + const res = await axios.post(SERVER, form, { httpsAgent }); + return res.data; +} + +// Parse domains from raw table +function parseDomainsFromTable(text) { + const lines = text.split("\n"); + const domains = []; + + for (let line of lines) { + line = line.trim(); + if (!line.includes(".")) continue; + if (line.startsWith("DOMAIN")) continue; + if (line.startsWith("------")) continue; + + const parts = line.split(/\s+/); + const domain = parts[0]; + + if (domain && domain.includes(".")) { + domains.push(domain); + } + } + + return domains; +} + +// Remove SSL certificate +async function removeSsl(domain) { + return hestia("v-delete-web-domain-ssl", { + arg1: HESTIA_USER, + arg2: domain, + }); +} + +// Add Let's Encrypt SSL +async function addSsl(domain) { + return hestia("v-add-letsencrypt-domain", { + arg1: HESTIA_USER, + arg2: domain, + }); +} + +// Remove + Add (renew) +async function refreshSsl(domain) { + const removed = await removeSsl(domain); + const added = await addSsl(domain); + return { removed, added }; +} + +function parseRawTable(text) { + const lines = text.split("\n").map(l => l.trim()).filter(Boolean); + + const dataRows = []; + + // Skip first 2 header lines + for (let i = 2; i < lines.length; i++) { + const line = lines[i]; + const parts = line.split(/\s+/); + + // Expect at least 8 columns + if (parts.length < 8) continue; + + const [ + domain, + ip, + tpl, + ttl, + dnssec, + rec, + spnd, + date + ] = parts; + + dataRows.push({ + domain, + ip, + tpl, + ttl: Number(ttl), + dnssec, + rec: Number(rec), + spnd, + date + }); + } + + return dataRows; +} + + + + +// =============================== +// ๐Ÿš€ E X P R E S S A P I +// =============================== + +const app = express(); +app.use(express.json()); + +// Health +app.get("/", (req, res) => { + res.json({ running: true, user: HESTIA_USER }); +}); + +// Get all DNS domains +app.get("/dns/domains", async (req, res) => { + try { + const raw = await getRawDomainList(); + + const domains = parseDomainsFromTable(raw); + const rawParsed = parseRawTable(raw); + + res.json({ + success: true, + domains, + rawParsed + }); + } catch (err) { + res.status(500).json({ + success: false, + error: err.response?.data || err.message + }); + } +}); + + +// Remove SSL +app.post("/ssl/remove", async (req, res) => { + const { domain } = req.body; + + if (!domain) { + return res.status(400).json({ success: false, error: "domain is required" }); + } + + try { + const result = await removeSsl(domain); + res.json({ success: true, domain, result }); + } catch (err) { + res.status(500).json({ + success: false, + domain, + error: err.response?.data || err.message, + }); + } +}); + +// Add SSL +app.post("/ssl/add", async (req, res) => { + const { domain } = req.body; + + if (!domain) { + return res.status(400).json({ success: false, error: "domain is required" }); + } + + try { + const result = await addSsl(domain); + res.json({ success: true, domain, result }); + } catch (err) { + res.status(500).json({ + success: false, + domain, + error: err.response?.data || err.message, + }); + } +}); + +// Refresh SSL +app.post("/ssl/refresh", async (req, res) => { + const { domain } = req.body; + + if (!domain) { + return res.status(400).json({ success: false, error: "domain is required" }); + } + + try { + const result = await refreshSsl(domain); + res.json({ success: true, domain, result }); + } catch (err) { + res.status(500).json({ + success: false, + domain, + error: err.response?.data || err.message, + }); + } +}); + +// Refresh SSL for ALL domains +app.post("/ssl/refresh-all", async (req, res) => { + try { + const raw = await getRawDomainList(); + const domains = parseDomainsFromTable(raw); + + const results = []; + + for (const domain of domains) { + try { + const result = await refreshSsl(domain); + results.push({ domain, success: true, result }); + } catch (e) { + results.push({ + domain, + success: false, + error: e.response?.data || e.message, + }); + } + } + + res.json({ + success: true, + user: HESTIA_USER, + results, + }); + } catch (err) { + res.status(500).json({ + success: false, + error: err.response?.data || err.message, + }); + } +}); + +// Start server +const PORT = process.env.PORT || 3015; +app.listen(PORT, () => { + console.log(`๐Ÿ”ฅ SSL Manager API running at port ${PORT}`); +}); diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/SSL_CRON.js b/SSL_CRON.js new file mode 100755 index 0000000..a6335cf --- /dev/null +++ b/SSL_CRON.js @@ -0,0 +1,173 @@ +// sslCron.mjs + +import cron from "node-cron"; +import axios from "axios"; +import { promises as fs } from "fs"; +import path from "path"; + +// Base URL of your SSL manager Express API +// e.g. the server where you defined /dns/domains and /ssl/refresh +const API_BASE = + process.env.SSL_MANAGER_URL || "https://api.hestiacp.metatronhost.com"; + +// Logging +const LOG_DIR = process.env.LOG_DIR || "/var/log/ssl-manager"; +const LOG_FILE = process.env.LOG_FILE || path.join(LOG_DIR, "sslCron.log"); + +async function ensureLogPath() { + await fs.mkdir(LOG_DIR, { recursive: true }); +} + +function safeStringify(obj) { + try { + return JSON.stringify(obj); + } catch { + return String(obj); + } +} + +async function logLine(level, message, meta = null) { + const ts = new Date().toISOString(); + const line = + `[${ts}] [${level}] ${message}` + + (meta ? ` | ${safeStringify(meta)}` : "") + + "\n"; + + if (level === "ERROR") console.error(line.trim()); + else console.log(line.trim()); + + try { + await ensureLogPath(); + await fs.appendFile(LOG_FILE, line, "utf8"); + } catch (e) { + console.error( + `[${ts}] [ERROR] Failed to write cron log file: ${e.message || e}` + ); + } +} + +/** + * Parse "notAfter" like: "Mar 11 19:08:24 2026 GMT" + */ +function parseNotAfter(notAfterStr) { + if (!notAfterStr) return null; + const d = new Date(notAfterStr); + if (isNaN(d.getTime())) return null; + return d; +} + +/** + * Return days left until SSL expiry from notAfter. + * If invalid โ†’ return large negative number. + */ +function daysLeftFromSsl(notAfterStr) { + const expiry = parseNotAfter(notAfterStr); + if (!expiry) return -9999; + + const now = new Date(); + const diffMs = expiry.getTime() - now.getTime(); + const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24)); + return diffDays; +} + +/** + * Decide if SSL is expired based on notAfter + */ +function isSslExpired(notAfterStr) { + const expiry = parseNotAfter(notAfterStr); + if (!expiry) return true; + const now = new Date(); + return now > expiry; +} + +/** + * One cycle: + * - Fetch domain list (/dns/domains) + * - For each domain, look at ssl.notAfter + * - If expired -> call POST /ssl/refresh + * (Your API handles: remove+add + notify reverse proxy + logs) + */ +async function checkAndRenewOnce() { + await logLine("INFO", "๐Ÿ” [SSL CRON] Cycle started", { API_BASE }); + + try { + await logLine("INFO", "Fetching domains", { url: `${API_BASE}/dns/domains` }); + + const res = await axios.get(`${API_BASE}/dns/domains`, { timeout: 60_000 }); + + if (!res.data?.success) { + await logLine("ERROR", "/dns/domains failed", { data: res.data }); + return; + } + + const rawParsed = res.data.rawParsed || []; + await logLine("INFO", "Domains fetched", { count: rawParsed.length }); + + for (const row of rawParsed) { + const domain = row?.domain; + const ssl = row?.ssl || null; + + const notAfter = ssl?.notAfter || null; + const daysLeft = daysLeftFromSsl(notAfter); + const expired = isSslExpired(notAfter); + + await logLine("INFO", "Domain status", { + domain, + notAfter, + daysLeft, + expired, + }); + + if (!domain) continue; + if (!expired) continue; + + // โœ… Actually renew via your API (which also notifies reverse proxy if exists) + try { + await logLine("INFO", "Renewing SSL via /ssl/refresh", { + domain, + url: `${API_BASE}/ssl/refresh`, + }); + + const refreshRes = await axios.post( + `${API_BASE}/ssl/refresh`, + { domain }, + { timeout: 120_000 } + ); + + if (refreshRes.data?.success) { + await logLine("INFO", "โœ… SSL renewed", { + domain, + response: refreshRes.data, + }); + } else { + await logLine("ERROR", "โš ๏ธ Renew failed (API returned success=false)", { + domain, + response: refreshRes.data, + }); + } + } catch (err) { + await logLine("ERROR", "โŒ Error renewing SSL", { + domain, + error: err?.response?.data || err?.message || String(err), + status: err?.response?.status || null, + }); + } + } + + await logLine("INFO", "๐ŸŽฏ [SSL CRON] Cycle completed"); + } catch (err) { + await logLine("ERROR", "โŒ Error fetching domains", { + error: err?.response?.data || err?.message || String(err), + status: err?.response?.status || null, + }); + } +} + +// ๐Ÿ” Schedule to run once per day at 03:00 server time +cron.schedule("0 3 * * *", async () => { + await logLine("INFO", "โฐ [SSL CRON] Daily job triggered"); + await checkAndRenewOnce(); +}); + +// Optional: run immediately when starting the script +checkAndRenewOnce(); diff --git a/Test.js b/Test.js new file mode 100644 index 0000000..d0cd497 --- /dev/null +++ b/Test.js @@ -0,0 +1,125 @@ + + +import axios from "axios"; +import https from "https"; + +import dns from "node:dns"; +dns.setDefaultResultOrder("ipv4first"); + + + +const API = "vvQjauyYQ2YDY2Au-_DC4QO5MUPFiHNn"; +// const SERVER = "https://host.metatronhost.com:8083/api/"; +const SERVER = "https://127.0.0.1:8083/api/"; + +// Ignore self-signed SSL +const httpsAgent = new https.Agent({ + rejectUnauthorized: false, +}); + +// Generic Hestia API function +async function hestia(cmd, args = {}) { + const form = new URLSearchParams({ + hash: API, + cmd, + ...args, + }); + + // const res = await axios.post(SERVER, form, { httpsAgent }); + const res = await axios.post(SERVER, form, { + httpsAgent, + family: 4, +}); + return res.data; +} + +// 1) Fetch raw DNS table (your way) +async function getRawDomainList(user) { + const form = new URLSearchParams({ + hash: API, + cmd: "v-list-dns-domains", + arg1: user, + }); + + const res = await axios.post(SERVER, form, { + httpsAgent, + family: 4, +}); + // const res = await axios.post(SERVER, form, { httpsAgent }); + return res.data; // plain text +} + +// 2) Parse domains from the table +function parseDomainsFromTable(text) { + const lines = text.split("\n"); + const domains = []; + + for (let line of lines) { + line = line.trim(); + if (!line.includes(".")) continue; + if (line.startsWith("DOMAIN")) continue; + if (line.startsWith("------")) continue; + + const parts = line.split(/\s+/); + const domain = parts[0]; + + if (domain && domain.includes(".")) { + domains.push(domain); + } + } + + return domains; +} + +// 3) Remove SSL +async function removeSsl(user, domain) { + return hestia("v-delete-web-domain-ssl", { + arg1: user, + arg2: domain, + }); +} + +// 4) Add Let's Encrypt SSL (no email param) +async function addLetsEncrypt(user, domain) { + // v-add-letsencrypt-domain USER DOMAIN [ALIASES] [MAIL] + // Here: generate SSL for domain + www.domain, no mail cert + return hestia("v-add-letsencrypt-domain", { + arg1: user, + arg2: domain, + //arg3: `${domain}`, // aliases + // no arg4 (MAIL) -> defaults to "no" + }); +} + +(async () => { + const user = "user"; + + try { + console.log("๐Ÿ” Fetching DNS domain table..."); + const table = await getRawDomainList(user); + console.log(table); + + console.log("\n๐Ÿ” Parsing domain names..."); + const domains = parseDomainsFromTable(table); + console.log("Parsed domains:", domains); + + if (domains.length === 0) { + console.log("โŒ No domains found."); + return; + } + + const domain = "test.metatronhost.com"; // or domains[0] if you want auto-pick + console.log("\n๐ŸŸฆ Selected domain:", domain); + + console.log("\n๐Ÿ”ง Removing old SSL..."); + console.log(await removeSsl(user, domain)); + + console.log("\n๐Ÿ” Adding Let's Encrypt SSL..."); + console.log(await addLetsEncrypt(user, domain)); + + console.log("\nโœ… SSL refreshed successfully for:", domain); + } catch (err) { + console.error("โŒ ERROR:", err.response?.data || err.message || err); + } +})(); + diff --git a/index copy.js b/index copy.js new file mode 100755 index 0000000..182b02d --- /dev/null +++ b/index copy.js @@ -0,0 +1,713 @@ +// server.mjs (or server.js with "type": "module") + +import express from "express"; +import axios from "axios"; +import https from "https"; +import NodeCache from "node-cache"; +import { promises as fs } from "fs"; +import path from "path"; + + + +import dns from "node:dns"; +dns.setDefaultResultOrder("ipv4first"); + + +// ๐Ÿ‘‰ Environment / Secrets +const API = process.env.HESTIA_API_HASH || "GCzPEYiK2NYDgq0Pz2d-CRctVyStsxiE"; +const SERVER = + process.env.HESTIA_SERVER_URL ||"https://127.0.0.1:8083/api/" || "https://host.metatronnest.com:8083/api/"; + +// ๐Ÿ‘‰ FIXED Hestia username +const HESTIA_USER = "user"; + +// ๐Ÿง  SSL info cache (per domain, 1 day TTL) +const sslCache = new NodeCache({ + stdTTL: 60 * 60 * 24, // 24 hours + checkperiod: 60 * 60, // check every hour +}); + +// Ignore self-signed SSL +const httpsAgent = new https.Agent({ + rejectUnauthorized: false, +}); + +// =============================== +// ๐Ÿงพ L O G G I N G +// =============================== + +const LOG_DIR = process.env.LOG_DIR || "/var/log/ssl-manager"; +const LOG_FILE = process.env.LOG_FILE || path.join(LOG_DIR, "server.log"); + +async function ensureLogPath() { + await fs.mkdir(LOG_DIR, { recursive: true }); +} + +function safeStringify(obj) { + try { + return JSON.stringify(obj); + } catch { + return String(obj); + } +} + +async function logLine(level, message, meta = null) { + const ts = new Date().toISOString(); + const line = + `[${ts}] [${level}] ${message}` + + (meta ? ` | ${safeStringify(meta)}` : "") + + "\n"; + + // console log also + if (level === "ERROR") console.error(line.trim()); + else console.log(line.trim()); + + try { + await ensureLogPath(); + await fs.appendFile(LOG_FILE, line, "utf8"); + } catch (e) { + // if log file fails, don't crash server + console.error( + `[${ts}] [ERROR] Failed to write log file: ${e.message || e}` + ); + } +} + +// =============================== +// ๐Ÿ”Ž N G I N X P R O X Y P O R T +// =============================== + +const WEB_CONF_ROOT = process.env.WEB_CONF_ROOT || "/home/user/conf/web"; +const SERVER_IP = process.env.SERVER_IP || "147.93.40.215"; + +// Endpoint to notify when reverse proxy exists +const NEST_PROXY_ENDPOINT = + process.env.NEST_PROXY_ENDPOINT ||"http://147.93.40.215:9999/api/nginx/app"|| + "https://manage.api.metatronnest.com/proxy/nginx-app"; + +// Optional auth header if needed +const NEST_PROXY_TOKEN = process.env.NEST_PROXY_TOKEN || ""; + +// Separate agent (if you ever have self-signed on metatronnest, set to false) +// by default, keep secure for external endpoint +const nestHttpsAgent = new https.Agent({ + rejectUnauthorized: true, +}); + +function extractProxyPort(nginxConfText) { + // strip comments + const text = nginxConfText.replace(/#.*$/gm, ""); + + // match: proxy_pass http://127.0.0.1:3022; + // or: proxy_pass http://localhost:3022; + const m = text.match( + /proxy_pass\s+https?:\/\/(?:127\.0\.0\.1|localhost):(\d+)\s*;/i + ); + + if (!m) return null; + + const port = Number(m[1]); + if (!Number.isInteger(port) || port <= 0 || port > 65535) return null; + + return port; +} + +async function getDomainProxyInfo(domain) { + if (!domain || typeof domain !== "string") { + throw new Error("domain must be a non-empty string"); + } + + const confPath = path.join(WEB_CONF_ROOT, domain, "nginx.conf"); + + let nginxConf; + try { + nginxConf = await fs.readFile(confPath, "utf8"); + } catch (e) { + console.warn(`โš ๏ธ [Proxy Info] nginx.conf not found for domain ${domain}`,e); + return { + success: false, + domain, + serverIp: SERVER_IP, + port: null, + error: "nginx.conf not found", + }; + } + + const port = extractProxyPort(nginxConf); + + if (!port) { + return { + success: false, + domain, + serverIp: SERVER_IP, + port: null, + error: "proxy_pass not found in nginx.conf", + }; + } +console.log( { success: true, domain, serverIp: SERVER_IP, port }) + return { success: true, domain, serverIp: SERVER_IP, port }; +} + +/** + * If reverse proxy exists for domain, notify metatronnest endpoint + */ +async function notifyNestIfReverseProxy(domain, proxyInfo) { + try { + + + await logLine("INFO", "Reverse proxy check", { domain, proxyInfo }); + + if (!proxyInfo.success || !proxyInfo.port) { + await logLine("INFO", "No reverse proxy found, skipping notify", { + domain, + }); + return { notified: false, reason: "no_proxy", proxyInfo }; + } + + const payload = { + server_ip: proxyInfo.serverIp, + domain: proxyInfo.domain, + port: String(proxyInfo.port), + }; + + const headers = { + "Content-Type": "application/json", + }; + if (NEST_PROXY_TOKEN) headers["Authorization"] = `Bearer ${NEST_PROXY_TOKEN}`; + + await logLine("INFO", "Notifying metatronnest /proxy/nginx-app", { + endpoint: NEST_PROXY_ENDPOINT, + payload, + }); + + const resp = await axios.post(NEST_PROXY_ENDPOINT, payload, { + headers, + httpsAgent: nestHttpsAgent, + timeout: 20_000, + }); + + + + + await logLine("INFO", "metatronnest notify success", { + status: resp.status, + data: resp.data, + }); + + return { notified: true, payload, response: resp.data }; + } catch (err) { + await logLine("ERROR", "metatronnest notify failed", { + domain, + error: err?.response?.data || err?.message || String(err), + status: err?.response?.status || null, + }); + + return { + notified: false, + reason: "notify_failed", + error: err?.response?.data || err?.message || String(err), + }; + } +} + +// =============================== +// ๐Ÿ”ง H E S T I A H E L P E R S +// =============================== + +async function hestia(cmd, args = {}) { + const form = new URLSearchParams({ + hash: API, + cmd, + ...args, + }); + + const res = await axios.post(SERVER, form, { httpsAgent }); + return res.data; +} +// Fetch raw DNS domain table +async function getRawDomainList() { + const form = new URLSearchParams({ + hash: API, + cmd: "v-list-dns-domains", + arg1: HESTIA_USER, + }); + + const res = await axios.post(SERVER, form, { httpsAgent }); + return res.data; +} + +// Parse domains from raw table (only domain names) +function parseDomainsFromTable(text) { + const lines = text.split("\n"); + const domains = []; + + for (let line of lines) { + line = line.trim(); + if (!line.includes(".")) continue; + if (line.startsWith("DOMAIN")) continue; + if (line.startsWith("------")) continue; + + const parts = line.split(/\s+/); + const domain = parts[0]; + + if (domain && domain.includes(".")) { + domains.push(domain); + } + } + + return domains; +} + +// Parse the full DNS table into structured rows +function parseRawTable(text) { + const lines = text.split("\n").map((l) => l.trim()).filter(Boolean); + + const dataRows = []; + + // Skip first 2 header lines + for (let i = 2; i < lines.length; i++) { + const line = lines[i]; + const parts = line.split(/\s+/); + + // Expect at least 8 columns + if (parts.length < 8) continue; + + const [domain, ip, tpl, ttl, dnssec, rec, spnd, date] = parts; + + dataRows.push({ + domain, + ip, + tpl, + ttl: Number(ttl), + dnssec, + rec: Number(rec), + spnd, + date, + }); + } + + return dataRows; +} + +// Remove SSL certificate +async function removeSsl(domain) { + await logLine("INFO", "Removing SSL", { domain }); + return hestia("v-delete-web-domain-ssl", { + arg1: HESTIA_USER, + arg2: domain, + }); +} + +// Add Let's Encrypt SSL +async function addSsl(domain) { + await logLine("INFO", "Adding Let's Encrypt SSL", { domain }); + return hestia("v-add-letsencrypt-domain", { + arg1: HESTIA_USER, + arg2: domain, + }); +} + +// Remove + Add (renew) +async function refreshSsl(domain) { + await logLine("INFO", "Refreshing SSL (remove + add)", { domain }); + const removed = await removeSsl(domain); + const added = await addSsl(domain); + return { removed, added }; +} + +// โœ… Get REAL SSL info for a web domain, but return ONLY summary (no big CRT/KEY/CA) +async function getWebSslInfoSummary(domain) { + try { + // v-list-web-domain-ssl USER DOMAIN [FORMAT] + const data = await hestia("v-list-web-domain-ssl", { + arg1: HESTIA_USER, + arg2: domain, + arg3: "json", + }); + + let parsed = data; + + // If Hestia returns a string, try parse it + if (typeof data === "string") { + try { + parsed = JSON.parse(data); + } catch { + return { + success: true, + subject: null, + aliases: null, + notBefore: null, + notAfter: null, + issuer: null, + signature: null, + pubKey: null, + sslForce: null, + rawType: "string", + }; + } + } + + const keys = Object.keys(parsed || {}); + if (!keys.length) { + return { + success: false, + error: "No SSL data found in response", + }; + } + + const cert = parsed[keys[0]] || {}; + + return { + success: true, + subject: cert.SUBJECT || null, + aliases: cert.ALIASES || null, + notBefore: cert.NOT_BEFORE || null, + notAfter: cert.NOT_AFTER || null, + issuer: cert.ISSUER || null, + signature: cert.SIGNATURE || null, + pubKey: cert.PUB_KEY || null, + sslForce: cert.SSL_FORCE || null, + }; + } catch (err) { + return { + success: false, + error: err.response?.data || err.message || "Unknown error", + }; + } +} + +// =============================== +// ๐Ÿš€ E X P R E S S A P I +// =============================== + +const app = express(); +app.use(express.json()); + +// request logging +app.use(async (req, res, next) => { + const start = Date.now(); + res.on("finish", async () => { + await logLine("INFO", "HTTP", { + method: req.method, + path: req.originalUrl, + status: res.statusCode, + ms: Date.now() - start, + }); + }); + next(); +}); + +// Health +app.get("/", (req, res) => { + res.json({ running: true, user: HESTIA_USER }); +}); + +// โœ… Get proxy info for one domain +// Example: /proxy/info?domain=gmb.metatronhost.com +app.get("/proxy/info", async (req, res) => { + const domain = req.query.domain; + + if (!domain) { + return res + .status(400) + .json({ success: false, error: "domain query param is required" }); + } + + try { + const info = await getDomainProxyInfo(String(domain)); + return res.json(info); + } catch (err) { + return res.status(500).json({ + success: false, + domain, + error: err.message || "Unknown error", + }); + } +}); + +// โœ… Get proxy info for all domains (based on Hestia DNS list) +app.get("/proxy/all", async (req, res) => { + try { + const raw = await getRawDomainList(); + const domains = parseDomainsFromTable(raw); + + const results = []; + for (const domain of domains) { + results.push(await getDomainProxyInfo(domain)); + } + + res.json({ success: true, serverIp: SERVER_IP, results }); + } catch (err) { + res.status(500).json({ + success: false, + error: err.response?.data || err.message, + }); + } +}); + +// Get all DNS domains + SSL summary (cached) +app.get("/dns/domains", async (req, res) => { + try { + const raw = await getRawDomainList(); + + const domains = parseDomainsFromTable(raw); + const rawParsed = parseRawTable(raw); + + const sslInfoByDomain = {}; + + for (const domain of domains) { + const cacheKey = `ssl-${domain}`; + let summary = sslCache.get(cacheKey); + + if (!summary) { + summary = await getWebSslInfoSummary(domain); + sslCache.set(cacheKey, summary); + } + + sslInfoByDomain[domain] = summary; + } + + const rawParsedWithSsl = rawParsed.map((row) => ({ + ...row, + ssl: sslInfoByDomain[row.domain] || null, + })); + + res.json({ + success: true, + domains, + rawParsed: rawParsedWithSsl, + }); + } catch (err) { + console.error("Error in /dns/domains:", err); + res.status(500).json({ + success: false, + error: err.response?.data || err.message, + }); + } +}); + +// Remove SSL (only notify if reverse proxy exists) +app.post("/ssl/remove", async (req, res) => { + const { domain } = req.body; + + if (!domain) { + return res + .status(400) + .json({ success: false, error: "domain is required" }); + } + + try { + await logLine("INFO", "SSL REMOVE requested", { domain }); + + // const notify = await notifyNestIfReverseProxy(domain); + + const result = await removeSsl(domain); + + sslCache.del(`ssl-${domain}`); + + res.json({ success: true, domain, result }); + } catch (err) { + await logLine("ERROR", "SSL REMOVE failed", { + domain, + error: err.response?.data || err.message, + }); + + res.status(500).json({ + success: false, + domain, + error: err.response?.data || err.message, + }); + } +}); + +// Add SSL (only notify if reverse proxy exists) +app.post("/ssl/add", async (req, res) => { + const { domain } = req.body; + + if (!domain) { + return res + .status(400) + .json({ success: false, error: "domain is required" }); + } + + try { + await logLine("INFO", "SSL ADD requested", { domain }); + + + const proxyInfo = await getDomainProxyInfo(domain); + const result = await addSsl(domain); + + sslCache.del(`ssl-${domain}`); + const notify = await notifyNestIfReverseProxy(domain, proxyInfo); + res.json({ success: true, domain, notify, result }); + } catch (err) { + await logLine("ERROR", "SSL ADD failed", { + domain, + error: err.response?.data || err.message, + }); + + res.status(500).json({ + success: false, + domain, + error: err.response?.data || err.message, + }); + } +}); + +// Refresh SSL (only notify if reverse proxy exists) +app.post("/ssl/refresh", async (req, res) => { + const { domain } = req.body; + + if (!domain) { + return res + .status(400) + .json({ success: false, error: "domain is required" }); + } + + try { + await logLine("INFO", "SSL REFRESH requested", { domain }); + + const proxyInfo = await getDomainProxyInfo(domain); + + const result = await refreshSsl(domain); + + sslCache.del(`ssl-${domain}`); + const notify = await notifyNestIfReverseProxy(domain, proxyInfo); + + res.json({ success: true, domain, notify, result }); + } catch (err) { + await logLine("ERROR", "SSL REFRESH failed", { + domain, + error: err.response?.data || err.message, + }); + + res.status(500).json({ + success: false, + domain, + error: err.response?.data || err.message, + }); + } +}); + +// Refresh SSL for ALL domains (only notify if reverse proxy exists) +app.post("/ssl/refresh-all", async (req, res) => { + try { + await logLine("INFO", "SSL REFRESH-ALL requested", { user: HESTIA_USER }); + + const raw = await getRawDomainList(); + const domains = parseDomainsFromTable(raw); + + const results = []; + + for (const domain of domains) { + try { + await logLine("INFO", "Processing domain for refresh-all", { domain }); + + const proxyInfo = await getDomainProxyInfo(domain); + + const result = await refreshSsl(domain); + + sslCache.del(`ssl-${domain}`); + + const notify = await notifyNestIfReverseProxy(domain, proxyInfo); + + // results.push({ domain, success: true,proxyInfo }); + results.push({ domain, success: true, notify, result }); + } catch (e) { + await logLine("ERROR", "refresh-all domain failed", { + domain, + error: e.response?.data || e.message, + }); + + results.push({ + domain, + success: false, + error: e.response?.data || e.message, + }); + } + } + + res.json({ + success: true, + user: HESTIA_USER, + results, + }); + } catch (err) { + await logLine("ERROR", "SSL REFRESH-ALL failed", { + error: err.response?.data || err.message, + }); + + res.status(500).json({ + success: false, + error: err.response?.data || err.message, + }); + } +}); + +app.get("/reverse-proxy-info", async (req, res) => { + try { + await logLine("INFO", "SSL REFRESH-ALL requested", { user: HESTIA_USER }); + + const raw = await getRawDomainList(); + const domains = parseDomainsFromTable(raw); + + const results = []; + + for (const domain of domains) { + try { + await logLine("INFO", "Processing domain for refresh-all", { domain }); + + const proxyInfo = await getDomainProxyInfo(domain); + + // const result = await refreshSsl(domain); + + // sslCache.del(`ssl-${domain}`); + + // const notify = await notifyNestIfReverseProxy(domain, proxyInfo); + + results.push({ domain, success: true,proxyInfo }); + // results.push({ domain, success: true, notify, result }); + } catch (e) { + await logLine("ERROR", "reverse-proxy domain failed", { + domain, + error: e.response?.data || e.message, + }); + + results.push({ + domain, + success: false, + error: e.response?.data || e.message, + }); + } + } + + res.json({ + success: true, + user: HESTIA_USER, + results, + }); + } catch (err) { + await logLine("ERROR", "SSL REFRESH-ALL failed", { + error: err.response?.data || err.message, + }); + + res.status(500).json({ + success: false, + error: err.response?.data || err.message, + }); + } +}); + + +// Start server +const PORT = process.env.PORT || 3015; +app.listen(PORT, async () => { + await logLine("INFO", "๐Ÿ”ฅ SSL Manager API started", { + port: PORT, + user: HESTIA_USER, + serverIp: SERVER_IP, + webConfRoot: WEB_CONF_ROOT, + logFile: LOG_FILE, + nestEndpoint: NEST_PROXY_ENDPOINT, + }); +}); diff --git a/index.js b/index.js new file mode 100755 index 0000000..7ea73e5 --- /dev/null +++ b/index.js @@ -0,0 +1,714 @@ +// server.mjs (or server.js with "type": "module") + +import express from "express"; +import axios from "axios"; +import https from "https"; +import NodeCache from "node-cache"; +import { promises as fs } from "fs"; +import path from "path"; + + + +import dns from "node:dns"; +dns.setDefaultResultOrder("ipv4first"); + + +// ๐Ÿ‘‰ Environment / Secrets +const API = "vvQjauyYQ2YDY2Au-_DC4QO5MUPFiHNn"|| process.env.HESTIA_API_HASH || "GCzPEYiK2NYDgq0Pz2d-CRctVyStsxiE"; +const SERVER = + process.env.HESTIA_SERVER_URL ||"https://127.0.0.1:8083/api/" || "https://host.metatronnest.com:8083/api/"; + +// ๐Ÿ‘‰ FIXED Hestia username +const HESTIA_USER = "user"; + +// ๐Ÿง  SSL info cache (per domain, 1 day TTL) +const sslCache = new NodeCache({ + stdTTL: 60 * 60 * 24, // 24 hours + checkperiod: 60 * 60, // check every hour +}); + +// Ignore self-signed SSL +const httpsAgent = new https.Agent({ + rejectUnauthorized: false, +}); + +// =============================== +// ๐Ÿงพ L O G G I N G +// =============================== + +const LOG_DIR = process.env.LOG_DIR || "/var/log/ssl-manager"; +const LOG_FILE = process.env.LOG_FILE || path.join(LOG_DIR, "server.log"); + +async function ensureLogPath() { + await fs.mkdir(LOG_DIR, { recursive: true }); +} + +function safeStringify(obj) { + try { + return JSON.stringify(obj); + } catch { + return String(obj); + } +} + +async function logLine(level, message, meta = null) { + const ts = new Date().toISOString(); + const line = + `[${ts}] [${level}] ${message}` + + (meta ? ` | ${safeStringify(meta)}` : "") + + "\n"; + + // console log also + if (level === "ERROR") console.error(line.trim()); + else console.log(line.trim()); + + try { + await ensureLogPath(); + await fs.appendFile(LOG_FILE, line, "utf8"); + } catch (e) { + // if log file fails, don't crash server + console.error( + `[${ts}] [ERROR] Failed to write log file: ${e.message || e}` + ); + } +} + +// =============================== +// ๐Ÿ”Ž N G I N X P R O X Y P O R T +// =============================== + +const WEB_CONF_ROOT = process.env.WEB_CONF_ROOT || "/home/user/conf/web"; +const SERVER_IP = process.env.SERVER_IP || "147.93.40.215"; + +// Endpoint to notify when reverse proxy exists +const NEST_PROXY_ENDPOINT = + process.env.NEST_PROXY_ENDPOINT ||"http://147.93.40.215:9999/api/nginx/app"|| + "https://manage.api.metatronnest.com/proxy/nginx-app"; + +// Optional auth header if needed +const NEST_PROXY_TOKEN = process.env.NEST_PROXY_TOKEN || ""; + +// Separate agent (if you ever have self-signed on metatronnest, set to false) +// by default, keep secure for external endpoint +const nestHttpsAgent = new https.Agent({ + rejectUnauthorized: true, +}); + +function extractProxyPort(nginxConfText) { + // strip comments + const text = nginxConfText.replace(/#.*$/gm, ""); + + // match: proxy_pass http://127.0.0.1:3022; + // or: proxy_pass http://localhost:3022; + const m = text.match( + /proxy_pass\s+https?:\/\/(?:127\.0\.0\.1|localhost):(\d+)\s*;/i + ); + + if (!m) return null; + + const port = Number(m[1]); + if (!Number.isInteger(port) || port <= 0 || port > 65535) return null; + + return port; +} + +async function getDomainProxyInfo(domain) { + if (!domain || typeof domain !== "string") { + throw new Error("domain must be a non-empty string"); + } + + const confPath = path.join(WEB_CONF_ROOT, domain, "nginx.conf"); + + let nginxConf; + try { + nginxConf = await fs.readFile(confPath, "utf8"); + } catch (e) { + console.warn(`โš ๏ธ [Proxy Info] nginx.conf not found for domain ${domain}`,e); + return { + success: false, + domain, + serverIp: SERVER_IP, + port: null, + error: "nginx.conf not found", + }; + } + + const port = extractProxyPort(nginxConf); + + if (!port) { + return { + success: false, + domain, + serverIp: SERVER_IP, + port: null, + error: "proxy_pass not found in nginx.conf", + }; + } +console.log( { success: true, domain, serverIp: SERVER_IP, port }) + return { success: true, domain, serverIp: SERVER_IP, port }; +} + +/** + * If reverse proxy exists for domain, notify metatronnest endpoint + */ +async function notifyNestIfReverseProxy(domain, proxyInfo) { + try { + + + await logLine("INFO", "Reverse proxy check", { domain, proxyInfo }); + + if (!proxyInfo.success || !proxyInfo.port) { + await logLine("INFO", "No reverse proxy found, skipping notify", { + domain, + }); + return { notified: false, reason: "no_proxy", proxyInfo }; + } + + const payload = { + server_ip: proxyInfo.serverIp, + domain: proxyInfo.domain, + port: String(proxyInfo.port), + }; + + const headers = { + "Content-Type": "application/json", + }; + if (NEST_PROXY_TOKEN) headers["Authorization"] = `Bearer ${NEST_PROXY_TOKEN}`; + + await logLine("INFO", "Notifying metatronnest /proxy/nginx-app", { + endpoint: NEST_PROXY_ENDPOINT, + payload, + }); + + const resp = await axios.post(NEST_PROXY_ENDPOINT, payload, { + headers, + httpsAgent: nestHttpsAgent, + timeout: 20_000, + }); + + + + + await logLine("INFO", "metatronnest notify success", { + status: resp.status, + data: resp.data, + }); + + return { notified: true, payload, response: resp.data }; + } catch (err) { + await logLine("ERROR", "metatronnest notify failed", { + domain, + error: err?.response?.data || err?.message || String(err), + status: err?.response?.status || null, + }); + + return { + notified: false, + reason: "notify_failed", + error: err?.response?.data || err?.message || String(err), + }; + } +} + +// =============================== +// ๐Ÿ”ง H E S T I A H E L P E R S +// =============================== + +async function hestia(cmd, args = {}) { + const form = new URLSearchParams({ + hash: API, + cmd, + ...args, + }); + + const res = await axios.post(SERVER, form, { httpsAgent }); + return res.data; +} +// Fetch raw DNS domain table +async function getRawDomainList() { + const form = new URLSearchParams({ + hash: API, + cmd: "v-list-dns-domains", + arg1: HESTIA_USER, + }); + + const res = await axios.post(SERVER, form, { httpsAgent }); + return res.data; +} + +// Parse domains from raw table (only domain names) +function parseDomainsFromTable(text) { + const lines = text.split("\n"); + const domains = []; + + for (let line of lines) { + line = line.trim(); + if (!line.includes(".")) continue; + if (line.startsWith("DOMAIN")) continue; + if (line.startsWith("------")) continue; + + const parts = line.split(/\s+/); + const domain = parts[0]; + + if (domain && domain.includes(".")) { + domains.push(domain); + } + } + + return domains; +} + +// Parse the full DNS table into structured rows +function parseRawTable(text) { + const lines = text.split("\n").map((l) => l.trim()).filter(Boolean); + + const dataRows = []; + + // Skip first 2 header lines + for (let i = 2; i < lines.length; i++) { + const line = lines[i]; + const parts = line.split(/\s+/); + + // Expect at least 8 columns + if (parts.length < 8) continue; + + const [domain, ip, tpl, ttl, dnssec, rec, spnd, date] = parts; + + dataRows.push({ + domain, + ip, + tpl, + ttl: Number(ttl), + dnssec, + rec: Number(rec), + spnd, + date, + }); + } + + return dataRows; +} + +// Remove SSL certificate +async function removeSsl(domain) { + await logLine("INFO", "Removing SSL", { domain }); + return hestia("v-delete-web-domain-ssl", { + arg1: HESTIA_USER, + arg2: domain, + }); +} + +// Add Let's Encrypt SSL +async function addSsl(domain) { + await logLine("INFO", "Adding Let's Encrypt SSL", { domain }); + return hestia("v-add-letsencrypt-domain", { + arg1: HESTIA_USER, + arg2: domain, + }); +} + +// Remove + Add (renew) +async function refreshSsl(domain) { + await logLine("INFO", "Refreshing SSL (remove + add)", { domain }); + // const removed = await removeSsl(domain); + const added = await addSsl(domain); + // return { removed, added }; + return { added }; +} + +// โœ… Get REAL SSL info for a web domain, but return ONLY summary (no big CRT/KEY/CA) +async function getWebSslInfoSummary(domain) { + try { + // v-list-web-domain-ssl USER DOMAIN [FORMAT] + const data = await hestia("v-list-web-domain-ssl", { + arg1: HESTIA_USER, + arg2: domain, + arg3: "json", + }); + + let parsed = data; + + // If Hestia returns a string, try parse it + if (typeof data === "string") { + try { + parsed = JSON.parse(data); + } catch { + return { + success: true, + subject: null, + aliases: null, + notBefore: null, + notAfter: null, + issuer: null, + signature: null, + pubKey: null, + sslForce: null, + rawType: "string", + }; + } + } + + const keys = Object.keys(parsed || {}); + if (!keys.length) { + return { + success: false, + error: "No SSL data found in response", + }; + } + + const cert = parsed[keys[0]] || {}; + + return { + success: true, + subject: cert.SUBJECT || null, + aliases: cert.ALIASES || null, + notBefore: cert.NOT_BEFORE || null, + notAfter: cert.NOT_AFTER || null, + issuer: cert.ISSUER || null, + signature: cert.SIGNATURE || null, + pubKey: cert.PUB_KEY || null, + sslForce: cert.SSL_FORCE || null, + }; + } catch (err) { + return { + success: false, + error: err.response?.data || err.message || "Unknown error", + }; + } +} + +// =============================== +// ๐Ÿš€ E X P R E S S A P I +// =============================== + +const app = express(); +app.use(express.json()); + +// request logging +app.use(async (req, res, next) => { + const start = Date.now(); + res.on("finish", async () => { + await logLine("INFO", "HTTP", { + method: req.method, + path: req.originalUrl, + status: res.statusCode, + ms: Date.now() - start, + }); + }); + next(); +}); + +// Health +app.get("/", (req, res) => { + res.json({ running: true, user: HESTIA_USER }); +}); + +// โœ… Get proxy info for one domain +// Example: /proxy/info?domain=gmb.metatronhost.com +app.get("/proxy/info", async (req, res) => { + const domain = req.query.domain; + + if (!domain) { + return res + .status(400) + .json({ success: false, error: "domain query param is required" }); + } + + try { + const info = await getDomainProxyInfo(String(domain)); + return res.json(info); + } catch (err) { + return res.status(500).json({ + success: false, + domain, + error: err.message || "Unknown error", + }); + } +}); + +// โœ… Get proxy info for all domains (based on Hestia DNS list) +app.get("/proxy/all", async (req, res) => { + try { + const raw = await getRawDomainList(); + const domains = parseDomainsFromTable(raw); + + const results = []; + for (const domain of domains) { + results.push(await getDomainProxyInfo(domain)); + } + + res.json({ success: true, serverIp: SERVER_IP, results }); + } catch (err) { + res.status(500).json({ + success: false, + error: err.response?.data || err.message, + }); + } +}); + +// Get all DNS domains + SSL summary (cached) +app.get("/dns/domains", async (req, res) => { + try { + const raw = await getRawDomainList(); + + const domains = parseDomainsFromTable(raw); + const rawParsed = parseRawTable(raw); + + const sslInfoByDomain = {}; + + for (const domain of domains) { + const cacheKey = `ssl-${domain}`; + let summary = sslCache.get(cacheKey); + + if (!summary) { + summary = await getWebSslInfoSummary(domain); + sslCache.set(cacheKey, summary); + } + + sslInfoByDomain[domain] = summary; + } + + const rawParsedWithSsl = rawParsed.map((row) => ({ + ...row, + ssl: sslInfoByDomain[row.domain] || null, + })); + + res.json({ + success: true, + domains, + rawParsed: rawParsedWithSsl, + }); + } catch (err) { + console.error("Error in /dns/domains:", err); + res.status(500).json({ + success: false, + error: err.response?.data || err.message, + }); + } +}); + +// Remove SSL (only notify if reverse proxy exists) +app.post("/ssl/remove", async (req, res) => { + const { domain } = req.body; + + if (!domain) { + return res + .status(400) + .json({ success: false, error: "domain is required" }); + } + + try { + await logLine("INFO", "SSL REMOVE requested", { domain }); + + // const notify = await notifyNestIfReverseProxy(domain); + + const result = await removeSsl(domain); + + sslCache.del(`ssl-${domain}`); + + res.json({ success: true, domain, result }); + } catch (err) { + await logLine("ERROR", "SSL REMOVE failed", { + domain, + error: err.response?.data || err.message, + }); + + res.status(500).json({ + success: false, + domain, + error: err.response?.data || err.message, + }); + } +}); + +// Add SSL (only notify if reverse proxy exists) +app.post("/ssl/add", async (req, res) => { + const { domain } = req.body; + + if (!domain) { + return res + .status(400) + .json({ success: false, error: "domain is required" }); + } + + try { + await logLine("INFO", "SSL ADD requested", { domain }); + + + const proxyInfo = await getDomainProxyInfo(domain); + const result = await addSsl(domain); + + sslCache.del(`ssl-${domain}`); + const notify = await notifyNestIfReverseProxy(domain, proxyInfo); + res.json({ success: true, domain, notify, result }); + } catch (err) { + await logLine("ERROR", "SSL ADD failed", { + domain, + error: err.response?.data || err.message, + }); + + res.status(500).json({ + success: false, + domain, + error: err.response?.data || err.message, + }); + } +}); + +// Refresh SSL (only notify if reverse proxy exists) +app.post("/ssl/refresh", async (req, res) => { + const { domain } = req.body; + + if (!domain) { + return res + .status(400) + .json({ success: false, error: "domain is required" }); + } + + try { + await logLine("INFO", "SSL REFRESH requested", { domain }); + + const proxyInfo = await getDomainProxyInfo(domain); + + const result = await refreshSsl(domain); + + sslCache.del(`ssl-${domain}`); + const notify = await notifyNestIfReverseProxy(domain, proxyInfo); + + res.json({ success: true, domain, notify, result }); + } catch (err) { + await logLine("ERROR", "SSL REFRESH failed", { + domain, + error: err.response?.data || err.message, + }); + + res.status(500).json({ + success: false, + domain, + error: err.response?.data || err.message, + }); + } +}); + +// Refresh SSL for ALL domains (only notify if reverse proxy exists) +app.post("/ssl/refresh-all", async (req, res) => { + try { + await logLine("INFO", "SSL REFRESH-ALL requested", { user: HESTIA_USER }); + + const raw = await getRawDomainList(); + const domains = parseDomainsFromTable(raw); + + const results = []; + + for (const domain of domains) { + try { + await logLine("INFO", "Processing domain for refresh-all", { domain }); + + const proxyInfo = await getDomainProxyInfo(domain); + + const result = await refreshSsl(domain); + + sslCache.del(`ssl-${domain}`); + + const notify = await notifyNestIfReverseProxy(domain, proxyInfo); + + // results.push({ domain, success: true,proxyInfo }); + results.push({ domain, success: true, notify, result }); + } catch (e) { + await logLine("ERROR", "refresh-all domain failed", { + domain, + error: e.response?.data || e.message, + }); + + results.push({ + domain, + success: false, + error: e.response?.data || e.message, + }); + } + } + + res.json({ + success: true, + user: HESTIA_USER, + results, + }); + } catch (err) { + await logLine("ERROR", "SSL REFRESH-ALL failed", { + error: err.response?.data || err.message, + }); + + res.status(500).json({ + success: false, + error: err.response?.data || err.message, + }); + } +}); + +app.get("/reverse-proxy-info", async (req, res) => { + try { + await logLine("INFO", "SSL REFRESH-ALL requested", { user: HESTIA_USER }); + + const raw = await getRawDomainList(); + const domains = parseDomainsFromTable(raw); + + const results = []; + + for (const domain of domains) { + try { + await logLine("INFO", "Processing domain for refresh-all", { domain }); + + const proxyInfo = await getDomainProxyInfo(domain); + + // const result = await refreshSsl(domain); + + // sslCache.del(`ssl-${domain}`); + + // const notify = await notifyNestIfReverseProxy(domain, proxyInfo); + + results.push({ domain, success: true,proxyInfo }); + // results.push({ domain, success: true, notify, result }); + } catch (e) { + await logLine("ERROR", "reverse-proxy domain failed", { + domain, + error: e.response?.data || e.message, + }); + + results.push({ + domain, + success: false, + error: e.response?.data || e.message, + }); + } + } + + res.json({ + success: true, + user: HESTIA_USER, + results, + }); + } catch (err) { + await logLine("ERROR", "SSL REFRESH-ALL failed", { + error: err.response?.data || err.message, + }); + + res.status(500).json({ + success: false, + error: err.response?.data || err.message, + }); + } +}); + + +// Start server +const PORT = process.env.PORT || 3015; +app.listen(PORT, async () => { + await logLine("INFO", "๐Ÿ”ฅ SSL Manager API started", { + port: PORT, + user: HESTIA_USER, + serverIp: SERVER_IP, + webConfRoot: WEB_CONF_ROOT, + logFile: LOG_FILE, + nestEndpoint: NEST_PROXY_ENDPOINT, + }); +}); diff --git a/package-lock.json b/package-lock.json new file mode 100755 index 0000000..1ab032b --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1054 @@ +{ + "name": "Heatia_API", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "axios": "^1.13.2", + "express": "^5.2.1", + "node-cache": "^5.1.2", + "node-cron": "^4.2.1" + } + }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/accepts/node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/accepts/node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.2.tgz", + "integrity": "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.4", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/body-parser": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.1.tgz", + "integrity": "sha512-nfDwkulwiZYQIGwxdy0RUmowMhKcFVcYXUU7m4QlKYim1rUtg83xm2yjZ40QjDuc291AJjjeSc9b++AWHSgSHw==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.3", + "http-errors": "^2.0.0", + "iconv-lite": "^0.7.0", + "on-finished": "^2.4.1", + "qs": "^6.14.0", + "raw-body": "^3.0.1", + "type-is": "^2.0.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/clone": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz", + "integrity": "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==", + "license": "MIT", + "engines": { + "node": ">=0.8" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/content-disposition": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.0.1.tgz", + "integrity": "sha512-oIXISMynqSqm241k6kcQ5UwttDILMK4BiurCfGEREw6+X9jkkpEe5T9FZaApyLGGOnFuyMWZpdolTXMtvEJ08Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express/node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express/node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/follow-redirects": { + "version": "1.15.11", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", + "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.1.tgz", + "integrity": "sha512-2Tth85cXwGFHfvRgZWszZSvdo+0Xsqmw8k8ZwxScfcBneNUraK+dxRxRm24nszx80Y0TVio8kKLt5sLE7ZCLlw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-cache": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/node-cache/-/node-cache-5.1.2.tgz", + "integrity": "sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg==", + "license": "MIT", + "dependencies": { + "clone": "2.x" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/node-cron": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-4.2.1.tgz", + "integrity": "sha512-lgimEHPE/QDgFlywTd8yTR61ptugX3Qer29efeyWw2rv259HtGBNn1vZVmp8lB9uo9wC0t/AT4iGqXxia+CJFg==", + "license": "ISC", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.3.0.tgz", + "integrity": "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, + "node_modules/qs": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/send": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.0.tgz", + "integrity": "sha512-uaW0WwXKpL9blXE2o0bRhoL2EGXIrZxQ2ZQ4mgcfoBxdFmQold+qWsD2jLrfZ0trjKL6vOw0j//eAwcALFjKSw==", + "license": "MIT", + "dependencies": { + "debug": "^4.3.5", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "mime-types": "^3.0.1", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/send/node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/send/node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.0.tgz", + "integrity": "sha512-61g9pCh0Vnh7IutZjtLGGpTA355+OPn2TyDv/6ivP2h/AdAVX9azsoxmg2/M6nZeQZNYBEwIcsne1mJd9oQItQ==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "license": "MIT", + "dependencies": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/type-is/node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/type-is/node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + } + } +} diff --git a/package.json b/package.json new file mode 100755 index 0000000..6cd652f --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "dependencies": { + "axios": "^1.13.2", + "express": "^5.2.1", + "node-cache": "^5.1.2", + "node-cron": "^4.2.1" + } +}