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

View File

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

View File

@ -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/", ""))

View File

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

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