Refactor API for game file download and listing

Removed user registration and user info endpoints, along with related schemas, services, and tests. Added new routes and service for listing and downloading game files. Updated README to reflect new API purpose. Refactored logger and utils for improved modularity.
This commit is contained in:
2026-01-25 21:39:44 +01:00
parent 29cf189a87
commit cf54edf146
15 changed files with 104 additions and 128 deletions

10
routes/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

10
routes/gamefiles.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 gameIndex = await gameFilesService.getGameFiles()
return res.status(200).json(gameIndex)
})
module.exports = router

View File

@@ -1,15 +0,0 @@
const express = require("express")
const router = express.Router()
const registerService = require("../services/register")
router.post("/", async (req, res) => {
const { email, username, password } = req.body
const registerResult = registerService.register({ email, username, password })
return res.status(200).json({
code: 200,
message: "User successfully registered",
data: registerResult
})
})
module.exports = router

View File

@@ -1,17 +0,0 @@
const express = require("express")
const DefaultError = require("../../errors/DefaultError")
const router = express.Router()
router.get("", async (req, res) => {
const bearer = req.headers.authorization
if (bearer == "Bearer token") {
return res.status(200).json({
id: req.params.id,
username: "johndoe"
})
} else {
throw new DefaultError(403, "Invalid token", "", "InvalidTokenException")
}
})
module.exports = router