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.
This commit is contained in:
2026-01-25 21:47:49 +01:00
parent cf54edf146
commit 2e23d417af
4 changed files with 25 additions and 2 deletions

10
routes/api/v2/download.js Normal file
View File

@@ -0,0 +1,10 @@
const express = require("express")
const router = express.Router()
const gameFilesService = require("../../../services/gameDataService")
router.get(/.*/, async (req, res) => {
const fileRequest = await gameFilesService.getFile(req.baseUrl.replace("/download/", ""))
return res.status(fileRequest.code).sendFile(fileRequest.path)
})
module.exports = router

View File

@@ -0,0 +1,10 @@
const express = require("express")
const router = express.Router()
const gameFilesService = require("../../../services/gameDataService")
router.get("", async (req, res) => {
const gameIndex = await gameFilesService.getGameFiles()
return res.status(200).json(gameIndex)
})
module.exports = router

14
routes/api/v2/status.js Normal file
View File

@@ -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