azures04 e8f58e63cd Refactor texture handling and update route structure
Moved sessionserver routes to correct directory and removed subdirectory logic from texture file lookup. Updated texture URLs to remove leading slashes and fixed endpoint concatenation. Added default textures for Alex and Steve.
2025-12-28 22:22:54 +01:00

22 lines
645 B
JavaScript

const express = require("express")
const router = express.Router({ mergeParams: true })
const path = require("node:path")
const fs = require("node:fs")
const { DefaultError } = require("../../../errors/errors")
const TEXTURES_DIR = path.join(process.cwd(), "data", "textures")
router.get("/", async (req, res, next) => {
try {
const hash = req.params.hash
const filePath = path.join(TEXTURES_DIR, hash)
if (!fs.existsSync(filePath)) {
throw new DefaultError(404, "Texture not found")
}
res.sendFile(filePath)
} catch (err) {
return next(err)
}
})
module.exports = router