Add base project files including environment example, license, README, .gitignore, error classes, ESLint config, database modules, texture assets, repositories, routes, schemas, services, and server entry point. This establishes the foundational structure for a Yggdrasil-compatible REST API with modular error handling, database setup, and route organization.
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 |