"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"); 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); router.get("/status", queue.status); router.get("/status-data", queue.statusData); router.get("/status-summary", queue.statusSummary); router.post("/clear-captcha", queue.clearCaptcha); 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.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;