2024-05-04 14:44:23 +02:00
|
|
|
import express from "express";
|
|
|
|
import path from "path";
|
|
|
|
|
|
|
|
const webuiRouter = express.Router();
|
2024-05-28 13:28:57 +02:00
|
|
|
const rootDir = path.join(__dirname, "../..");
|
2024-06-02 14:31:49 +02:00
|
|
|
const repoDir = path.basename(rootDir) == "build" ? path.join(rootDir, "..") : rootDir;
|
2024-05-04 14:44:23 +02:00
|
|
|
|
2024-05-16 01:31:14 +02:00
|
|
|
// Redirect / to /webui/
|
2024-05-04 14:44:23 +02:00
|
|
|
webuiRouter.get("/", (_req, res) => {
|
|
|
|
res.redirect("/webui/");
|
|
|
|
});
|
|
|
|
|
2024-05-16 01:31:14 +02:00
|
|
|
// Redirect /webui to /webui/
|
|
|
|
webuiRouter.use("/webui", (req, res, next) => {
|
|
|
|
if (req.originalUrl === "/") {
|
|
|
|
return res.redirect("/webui/");
|
2024-05-04 14:44:23 +02:00
|
|
|
}
|
2024-05-16 01:31:14 +02:00
|
|
|
next();
|
2024-05-04 14:44:23 +02:00
|
|
|
});
|
|
|
|
|
2024-05-28 13:28:57 +02:00
|
|
|
// Serve virtual routes
|
|
|
|
webuiRouter.get("/webui/inventory", (_req, res) => {
|
|
|
|
res.sendFile(path.join(rootDir, "static/webui/index.html"));
|
|
|
|
});
|
|
|
|
webuiRouter.get("/webui/mods", (_req, res) => {
|
|
|
|
res.sendFile(path.join(rootDir, "static/webui/index.html"));
|
|
|
|
});
|
2024-06-27 23:08:59 +02:00
|
|
|
webuiRouter.get("/webui/settings", (_req, res) => {
|
|
|
|
res.sendFile(path.join(rootDir, "static/webui/index.html"));
|
|
|
|
});
|
|
|
|
webuiRouter.get("/webui/cheats", (_req, res) => {
|
|
|
|
res.sendFile(path.join(rootDir, "static/webui/index.html"));
|
|
|
|
});
|
2024-05-28 13:28:57 +02:00
|
|
|
|
|
|
|
// Serve static files
|
|
|
|
webuiRouter.use("/webui", express.static(path.join(rootDir, "static/webui")));
|
2024-05-04 14:44:23 +02:00
|
|
|
|
2024-05-30 13:32:58 +02:00
|
|
|
// Serve favicon
|
|
|
|
webuiRouter.get("/favicon.ico", (_req, res) => {
|
|
|
|
res.sendFile(path.join(rootDir, "static/fixed_responses/favicon.ico"));
|
|
|
|
});
|
|
|
|
|
2024-06-01 17:19:51 +02:00
|
|
|
// Serve warframe-riven-info
|
|
|
|
webuiRouter.get("/webui/riven-tool/", (_req, res) => {
|
2024-06-02 14:31:49 +02:00
|
|
|
res.sendFile(path.join(repoDir, "node_modules/warframe-riven-info/index.html"));
|
2024-06-01 17:19:51 +02:00
|
|
|
});
|
|
|
|
webuiRouter.get("/webui/riven-tool/RivenParser.js", (_req, res) => {
|
2024-06-02 14:31:49 +02:00
|
|
|
res.sendFile(path.join(repoDir, "node_modules/warframe-riven-info/RivenParser.js"));
|
2024-06-01 17:19:51 +02:00
|
|
|
});
|
|
|
|
|
2024-05-04 14:44:23 +02:00
|
|
|
export { webuiRouter };
|