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.
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
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)
|
|
}
|
|
|
|
serialize() {
|
|
const response = {}
|
|
|
|
if (this.path && this.path.trim() !== "") {
|
|
response.path = this.path.replace(/:(\w+)/g, "<$1>")
|
|
}
|
|
|
|
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 = ServiceError |