From 2e23d417afa4ba42e5feae01f7de245271e5254e Mon Sep 17 00:00:00 2001 From: azures04 Date: Sun, 25 Jan 2026 21:47:49 +0100 Subject: [PATCH] Refactor API routes and add status endpoint Moved download and gamefiles routes to api/v2 directory and updated service imports. Added a new api/v2/status endpoint to report maintenance status. Introduced api/v1/file route to return 410 error for deprecated launcher support. --- routes/api/v1/file/index.js | 9 +++++++++ routes/{ => api/v2}/download.js | 2 +- routes/{ => api/v2}/gamefiles.js | 2 +- routes/api/v2/status.js | 14 ++++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 routes/api/v1/file/index.js rename routes/{ => api/v2}/download.js (74%) rename routes/{ => api/v2}/gamefiles.js (69%) create mode 100644 routes/api/v2/status.js diff --git a/routes/api/v1/file/index.js b/routes/api/v1/file/index.js new file mode 100644 index 0000000..f0d5c99 --- /dev/null +++ b/routes/api/v1/file/index.js @@ -0,0 +1,9 @@ +const express = require("express") +const router = express.Router() +const { DefaultError } = require("../../../../errors/errors") + +router.get(/.*/, async (req, res) => { + throw new DefaultError(410, "Support for old launcher permanently removed.") +}) + +module.exports = router \ No newline at end of file diff --git a/routes/download.js b/routes/api/v2/download.js similarity index 74% rename from routes/download.js rename to routes/api/v2/download.js index dda6cb6..d402830 100644 --- a/routes/download.js +++ b/routes/api/v2/download.js @@ -1,6 +1,6 @@ const express = require("express") const router = express.Router() -const gameFilesService = require("../services/gameDataService") +const gameFilesService = require("../../../services/gameDataService") router.get(/.*/, async (req, res) => { const fileRequest = await gameFilesService.getFile(req.baseUrl.replace("/download/", "")) diff --git a/routes/gamefiles.js b/routes/api/v2/gamefiles.js similarity index 69% rename from routes/gamefiles.js rename to routes/api/v2/gamefiles.js index 48ac79c..4e33182 100644 --- a/routes/gamefiles.js +++ b/routes/api/v2/gamefiles.js @@ -1,6 +1,6 @@ const express = require("express") const router = express.Router() -const gameFilesService = require("../services/gameDataService") +const gameFilesService = require("../../../services/gameDataService") router.get("", async (req, res) => { const gameIndex = await gameFilesService.getGameFiles() diff --git a/routes/api/v2/status.js b/routes/api/v2/status.js new file mode 100644 index 0000000..23bf782 --- /dev/null +++ b/routes/api/v2/status.js @@ -0,0 +1,14 @@ +const express = require("express") +const router = express.Router() +const utils = require("../../../modules/utils") + +router.get("", async (req, res) => { + return res.status(200).json({ + maintenance: { + enabled: utils.isTrueFromDotEnv("MAINTENANCE"), + message: process.env.MANTENANCE_MESSAGE || "Launcher is on maintenance." + } + }) +}) + +module.exports = router \ No newline at end of file