phase 2 rework

This commit is contained in:
admin_rb committed 2026-10-23 18:19:44 +02:00
1 parent 20054198f3
commit b397ea9256
44 files changed
+5528 -1377

No files matched your search

+17 -58
View File
@@ -1,75 +1,34 @@
// routes/index.js
"use strict";
const express = require("express");
const router = express.Router();
const queue = require("../controllers/queueController");
const dashboard = require("../controllers/dashboardController");
const pm2 = require("../controllers/pm2Controller");
const { getDb } = require("../lib/mongo");
// =======================
// HOME PAGE
// =======================
router.get("/", (req, res) =>
res.render("index", { title: "Proxer Downloader" })
);
// =======================
// QUEUE REQUEST
// =======================
router.get("/", (req, res, next) => {
// Preserve bookmarks to the former download form's no-JavaScript mode links.
if (["series", "video"].includes(req.query.mode)) return res.redirect(`/download?mode=${req.query.mode}`);
return dashboard.dashboard(req, res, next);
});
router.get("/dashboard-data", dashboard.dashboardData);
router.get("/download", queue.home);
router.post("/queue", queue.enqueue);
// =======================
// STATUS (SSR RENDER)
// =======================
router.get("/status", queue.status);
// =======================
// STATUS JSON API
// =======================
router.get("/status-data", queue.statusData);
// =======================
// CAPTCHA CLEAR
// =======================
router.get("/status-summary", queue.statusSummary);
router.post("/clear-captcha", queue.clearCaptcha);
router.post("/clear-failed", async (req, res) => {
const db = await getDb();
await db
.collection("failed")
.deleteMany({}) //delete all
// Redirect to status, controller fetches everything
res.redirect("/status");
});
router.post("/clear-done", async (req, res) => {
const db = await getDb();
await db
.collection("done")
.deleteMany({}) //delete all
// Redirect to status, controller fetches everything
res.redirect("/status");
});
// Keep the legacy URL, but never release a job that may still have a live child process.
router.post("/clear-state", queue.clearState);
for (const state of ["queued", "done", "failed"]) {
router.post(`/clear-${state}`, (req, res, next) => queue.clearState(req, res, next, state));
}
// Retain the legacy URL without releasing a possibly live download.
router.post("/clear-processing", queue.clearProcessing);
router.post("/clear-queued", async (req, res) => {
const db = await getDb();
await db
.collection("queue")
.deleteMany({ processing: { $ne: true } }) //delete all not currently processing
// Redirect to status, controller fetches everything
res.redirect("/status");
});
// =======================
// PM2 MANAGEMENT
// =======================
router.get("/pm2", pm2.getManage);
router.get("/pm2/list-json", pm2.listJson);
router.post("/pm2/command", pm2.postCommand);
router.post("/pm2/quick-add", pm2.quickAdd);
module.exports = router;