2024-01-08 02:29:56 +00:00
|
|
|
import express from "express";
|
2024-01-12 07:43:58 +00:00
|
|
|
export const router = express.Router();
|
2024-01-08 02:29:56 +00:00
|
|
|
|
2024-01-11 05:31:13 +00:00
|
|
|
// Controllers
|
2024-01-12 01:51:26 +00:00
|
|
|
import { Login, submitLogin, Logout } from "../controllers/login.js";
|
2024-01-08 02:29:56 +00:00
|
|
|
import { Register, submitRegister } from "../controllers/register.js";
|
2024-03-19 00:14:47 +00:00
|
|
|
import { Dashboard, Logs, Modals, Stats, Chart, SSE, Card, updateCards, Containers, Action } from "../controllers/dashboard.js";
|
2024-03-17 08:00:11 +00:00
|
|
|
import { Apps, appSearch, InstallModal, LearnMore } from "../controllers/apps.js";
|
2024-01-08 02:29:56 +00:00
|
|
|
import { Users } from "../controllers/users.js";
|
2024-02-07 09:42:20 +00:00
|
|
|
import { Images, removeImage } from "../controllers/images.js";
|
|
|
|
import { Networks, removeNetwork } from "../controllers/networks.js";
|
|
|
|
import { Volumes, removeVolume } from "../controllers/volumes.js";
|
2024-01-08 02:29:56 +00:00
|
|
|
import { Account } from "../controllers/account.js";
|
2024-02-08 02:13:44 +00:00
|
|
|
import { Variables } from "../controllers/variables.js";
|
2024-01-08 02:29:56 +00:00
|
|
|
import { Settings } from "../controllers/settings.js";
|
2024-02-14 09:45:29 +00:00
|
|
|
import { Supporters, Thanks } from "../controllers/supporters.js";
|
2024-01-11 05:31:13 +00:00
|
|
|
import { Syslogs } from "../controllers/syslogs.js";
|
|
|
|
import { Portal } from "../controllers/portal.js"
|
2024-01-08 02:29:56 +00:00
|
|
|
|
2024-01-11 05:31:13 +00:00
|
|
|
// Auth middleware
|
2024-01-08 02:29:56 +00:00
|
|
|
const auth = (req, res, next) => {
|
|
|
|
if (req.session.role == "admin") {
|
|
|
|
next();
|
|
|
|
} else {
|
2024-01-11 08:05:38 +00:00
|
|
|
res.redirect("/login");
|
2024-01-08 02:29:56 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-02-19 02:23:20 +00:00
|
|
|
// Admin routes
|
2024-01-08 02:29:56 +00:00
|
|
|
router.get("/", auth, Dashboard);
|
2024-03-17 19:10:16 +00:00
|
|
|
router.post("/action/:action", auth, Action);
|
2024-03-17 08:00:11 +00:00
|
|
|
|
2024-02-14 09:45:29 +00:00
|
|
|
router.get("/logs", auth, Logs);
|
2024-03-17 19:10:16 +00:00
|
|
|
router.get("/modals", auth, Modals);
|
2024-02-14 09:45:29 +00:00
|
|
|
router.get("/stats", auth, Stats);
|
|
|
|
router.get("/chart", auth, Chart);
|
2024-03-12 23:23:37 +00:00
|
|
|
router.get("/sse_event", auth, SSE);
|
2024-03-15 04:12:09 +00:00
|
|
|
router.get("/containers", auth, Containers);
|
2024-03-12 23:23:37 +00:00
|
|
|
router.get("/card", auth, Card);
|
|
|
|
router.get("/new_cards", auth, updateCards);
|
2024-02-14 09:45:29 +00:00
|
|
|
|
2024-01-12 01:51:26 +00:00
|
|
|
router.get("/images", auth, Images);
|
2024-02-19 02:23:20 +00:00
|
|
|
router.post("/removeImage", auth, removeImage);
|
2024-02-06 08:35:16 +00:00
|
|
|
|
2024-01-12 01:51:26 +00:00
|
|
|
router.get("/volumes", auth, Volumes);
|
2024-02-17 08:37:07 +00:00
|
|
|
router.post("/removeVolume", auth, removeVolume);
|
2024-02-06 08:35:16 +00:00
|
|
|
|
2024-01-12 01:51:26 +00:00
|
|
|
router.get("/networks", auth, Networks);
|
2024-02-19 02:23:20 +00:00
|
|
|
router.post("/removeNetwork", auth, removeNetwork);
|
2024-01-08 02:29:56 +00:00
|
|
|
|
|
|
|
router.get("/apps", auth, Apps);
|
|
|
|
router.get("/apps/:page", auth, Apps);
|
2024-01-12 01:51:26 +00:00
|
|
|
router.post("/apps", auth, appSearch);
|
2024-03-17 08:00:11 +00:00
|
|
|
router.get("/install_modal", auth, InstallModal)
|
|
|
|
router.get("/learn_more", auth, LearnMore)
|
2024-01-08 02:29:56 +00:00
|
|
|
|
|
|
|
router.get("/users", auth, Users);
|
|
|
|
router.get("/syslogs", auth, Syslogs);
|
|
|
|
|
2024-02-08 02:13:44 +00:00
|
|
|
router.get("/variables", auth, Variables);
|
2024-01-08 02:29:56 +00:00
|
|
|
router.get("/settings", auth, Settings);
|
2024-02-14 09:45:29 +00:00
|
|
|
|
2024-02-19 02:23:20 +00:00
|
|
|
// User routes
|
|
|
|
router.get("/portal", Portal);
|
|
|
|
router.get("/account", Account);
|
2024-02-03 23:09:20 +00:00
|
|
|
router.get("/supporters", Supporters);
|
2024-02-14 09:45:29 +00:00
|
|
|
router.post("/thank", Thanks);
|
2024-01-11 05:31:13 +00:00
|
|
|
|
2024-02-19 02:23:20 +00:00
|
|
|
router.get("/login", Login);
|
|
|
|
router.post("/login", submitLogin);
|
|
|
|
router.get("/register", Register);
|
|
|
|
router.post("/register", submitRegister);
|
|
|
|
router.get("/logout", Logout);
|
|
|
|
|
2024-02-07 09:42:20 +00:00
|
|
|
|
2024-01-12 01:51:26 +00:00
|
|
|
// Functions
|
2024-03-17 09:20:32 +00:00
|
|
|
import { Install } from "../functions/install.js"
|
2024-02-07 09:42:20 +00:00
|
|
|
import { Uninstall } from "../functions/uninstall.js"
|
|
|
|
|
2024-03-17 09:20:32 +00:00
|
|
|
router.post("/install", auth, Install);
|
2024-03-01 07:14:08 +00:00
|
|
|
router.post("/uninstall", auth, Uninstall);
|