generated from azures04/Base-REST-API
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:
parent
cf54edf146
commit
2e23d417af
9
routes/api/v1/file/index.js
Normal file
9
routes/api/v1/file/index.js
Normal 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
|
||||
@ -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/", ""))
|
||||
@ -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
14
routes/api/v2/status.js
Normal 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
|
||||
Loading…
x
Reference in New Issue
Block a user