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.
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
const express = require("express")
|
|
const router = express.Router({ mergeParams: true })
|
|
const sessionsService = require("../../../../../services/sessionsService")
|
|
const { SessionError, DefaultError } = require("../../../../../errors/errors")
|
|
|
|
router.get("", async (req, res) => {
|
|
const { uuid } = req.params
|
|
const { unsigned } = req.query
|
|
const isUnsigned = (unsigned == undefined || unsigned == "true") ? true : false
|
|
|
|
try {
|
|
const result = await sessionsService.getProfile({
|
|
uuid: uuid,
|
|
unsigned: isUnsigned
|
|
})
|
|
if (result.code === 200) {
|
|
return res.status(200).json(result.data)
|
|
}
|
|
if (result.code === 204) {
|
|
throw new SessionError(404, undefined, "Not a valid UUID", req.originalUrl)
|
|
}
|
|
throw new DefaultError(500, undefined, "Unknown error", req.originalUrl)
|
|
} catch (err) {
|
|
const errorMessage = err.message || "Not a valid UUID"
|
|
throw new SessionError(400, undefined, errorMessage, req.originalUrl)
|
|
}
|
|
})
|
|
|
|
module.exports = router |