feat: refactor license download handling into a separate function
This commit is contained in:
@@ -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 {
|
try {
|
||||||
const { key, hostname, version = "latest" } = req.body || {};
|
|
||||||
if (!key || !hostname) {
|
if (!key || !hostname) {
|
||||||
return res.status(400).json({ error: "Licentiecode en hostname zijn verplicht." });
|
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();
|
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));
|
app.use(express.static(PATHS.distDir));
|
||||||
|
|||||||
Reference in New Issue
Block a user