From 3cf7e76d217cd6220f9e671251ed9389c38fc88e Mon Sep 17 00:00:00 2001 From: Roberto Guagliardo Date: Sun, 1 Feb 2026 04:49:25 +0000 Subject: [PATCH] feat: refactor license download handling into a separate function --- server/index.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/server/index.js b/server/index.js index 6f3f02d..2c72759 100644 --- a/server/index.js +++ b/server/index.js @@ -642,9 +642,8 @@ app.post("/api/licenses/verify", async (req, res) => { } }); -app.post("/api/licenses/download", async (req, res) => { +async function handleLicenseDownload(res, { key, hostname, version = "latest" }) { try { - const { key, hostname, version = "latest" } = req.body || {}; if (!key || !hostname) { return res.status(400).json({ error: "Licentiecode en hostname zijn verplicht." }); } @@ -685,6 +684,22 @@ app.post("/api/licenses/download", async (req, res) => { res.end(); } } +} + +app.post("/api/licenses/download", async (req, res) => { + await handleLicenseDownload(res, { + key: req.body?.key, + hostname: req.body?.hostname, + version: req.body?.version || "latest" + }); +}); + +app.get("/api/licenses/download", async (req, res) => { + await handleLicenseDownload(res, { + key: req.query.key, + hostname: req.query.hostname, + version: req.query.version || "latest" + }); }); app.use(express.static(PATHS.distDir));