Add Minecraft services API routes and user service

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.
This commit is contained in:
2025-12-28 07:15:24 +01:00
parent 228345c859
commit 5dd1de1521
32 changed files with 1235 additions and 62 deletions

View File

@@ -1,10 +1,12 @@
class AccountsAPIError extends Error {
constructor(code, path, error, errorMessage) {
class ServiceError extends Error {
constructor(code, path, error, errorMessage, details = null) {
super(errorMessage || error || "Accounts API Error")
this.code = code
this.path = path
this.errorType = error
this.errorMessage = errorMessage
this.developerMessage = errorMessage
this.details = details
this.isOperational = true
Error.captureStackTrace(this, this.constructor)
@@ -19,14 +21,23 @@ class AccountsAPIError extends Error {
if (this.errorType && this.errorType.trim() !== "") {
response.error = this.errorType
response.errorType = this.errorType
}
if (this.details) {
response.details = this.details
}
if (this.errorMessage && this.errorMessage.trim() !== "") {
response.errorMessage = this.errorMessage
}
if (this.developerMessage && this.developerMessage.trim() !== "") {
response.developerMessage = this.developerMessage
}
return response
}
}
module.exports = AccountsAPIError
module.exports = ServiceError

View File

@@ -1,4 +1,5 @@
const DefaultError = require("./DefaultError")
const ServiceError = require("./ServiceError")
const SessionError = require("./SessionError")
const YggdrasilError = require("./YggdrasilError")
const ValidationError = require("./ValidationError")
@@ -6,6 +7,7 @@ const ValidationError = require("./ValidationError")
module.exports = {
DefaultError,
SessionError,
ServiceError,
YggdrasilError,
ValidationError
}