Introduces new routes under /minecraftservices and /mojangapi for profile, skin, cape, blocklist, privileges, and certificate management. Adds a comprehensive userService module to handle user-related operations, and extends userRepository with methods for username changes, skin/cape management, blocking, and profile lookups. Refactors username availability logic into authService, updates error handling, and improves logger and utility functions. Also updates route handlers to use consistent return statements and enhances route registration logging.
39 lines
1.4 KiB
JavaScript
39 lines
1.4 KiB
JavaScript
const express = require("express")
|
|
const router = express.Router()
|
|
const utils = require("../../../modules/utils") // Pour addDashesToUUID
|
|
const authService = require("../../../services/authService")
|
|
const userService = require("../../../services/userService")
|
|
|
|
router.get("/", async (req, res, next) => {
|
|
const user = await authService.verifyUserFromHeader(req.headers.authorization)
|
|
const result = await userService.getBlockedUuids(user.uuid)
|
|
return res.status(200).json({
|
|
blockedProfiles: result.data || []
|
|
})
|
|
})
|
|
|
|
router.put("/:uuid", async (req, res, next) => {
|
|
const user = await authService.verifyUserFromHeader(req.headers.authorization)
|
|
const targetUuid = utils.addDashesToUUID(req.params.uuid)
|
|
|
|
await userService.blockPlayer(user.uuid, targetUuid)
|
|
|
|
const result = await userService.getBlockedUuids(user.uuid)
|
|
return res.status(200).json({
|
|
blockedProfiles: result.data || []
|
|
})
|
|
})
|
|
|
|
router.delete("/:uuid", async (req, res, next) => {
|
|
const user = await authService.verifyUserFromHeader(req.headers.authorization)
|
|
const targetUuid = utils.addDashesToUUID(req.params.uuid)
|
|
|
|
await userService.unblockPlayer(user.uuid, targetUuid)
|
|
|
|
const result = await userService.getBlockedUuids(user.uuid)
|
|
return res.status(200).json({
|
|
blockedProfiles: result.data || []
|
|
})
|
|
})
|
|
|
|
module.exports = router |