Initial project structure and core files

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.
This commit is contained in:
2026-01-05 04:42:39 +01:00
commit 587146d322
112 changed files with 8540 additions and 0 deletions
@@ -0,0 +1,9 @@
const z = require("zod")
module.exports = {
DELETE: {
query: z.object({
hash: z.string().length(64)
})
}
}
+9
View File
@@ -0,0 +1,9 @@
const z = require("zod")
module.exports = {
GET: {
query: z.object({
uuid: z.string().uuid()
})
}
}
+9
View File
@@ -0,0 +1,9 @@
const z = require("zod")
module.exports = {
GET: {
query: z.object({
uuid: z.string().uuid()
})
}
}
+26
View File
@@ -0,0 +1,26 @@
const z = require("zod")
const uuidSchema = z.object({
uuid: z.string().uuid()
})
module.exports = {
GET: {
query: uuidSchema
},
PUT: {
body: z.object({
reasonKey: z.string().min(1),
reasonMessage: z.string().optional(),
expires: z.number().int().positive().optional()
}),
error: {
code: 400,
error: "CONSTRAINT_VIOLATION",
errorMessage: "Invalid ban format"
}
},
DELETE: {
query: uuidSchema
}
}
+12
View File
@@ -0,0 +1,12 @@
const z = require("zod")
module.exports = {
PATCH: {
body: z.object({
newPassword: z.string()
.min(8, { message: "The password must be at least 8 characters long." })
.regex(/[A-Z]/, { message: "The password must contain a capital letter." })
.regex(/[0-9]/, { message: "The password must contain a number." }),
})
}
}
@@ -0,0 +1,16 @@
const z = require("zod")
module.exports = {
PUT: {
query: z.object({
uuid: z.string().uuid(),
hash: z.string().length(64)
})
},
DELETE: {
query: z.object({
uuid: z.string().uuid(),
hash: z.string().length(64)
})
}
}
@@ -0,0 +1,18 @@
const z = require("zod")
module.exports = {
POST: {
headers: z.object({
"content-type": z.string()
.regex(/application\/json/i, { message: "Content-Type must be application/json" })
}),
body: z.array(z.string().trim().min(1))
.min(1, { message: "RequestPayload is an empty array." })
.max(10, { message: "RequestPayload has more than 10 elements." }),
error: {
code: 400,
error: "CONSTRAINT_VIOLATION",
errorMessage: "size must be between 1 and 10"
}
}
}
@@ -0,0 +1,13 @@
const z = require("zod")
module.exports = {
GET: {
params: z.object({
username: z.string().min(1, { message: "Username is required." })
}),
error: {
code: 404,
message: "Not Found"
}
}
}
+18
View File
@@ -0,0 +1,18 @@
const z = require("zod")
module.exports = {
POST: {
headers: z.object({
"content-type": z.string()
.regex(/application\/json/i, { message: "Content-Type must be application/json" })
}),
body: z.array(z.string().trim().min(1))
.min(1, { message: "RequestPayload is an empty array." })
.max(10, { message: "RequestPayload has more than 10 elements." }),
error: {
code: 400,
error: "CONSTRAINT_VIOLATION",
errorMessage: "size must be between 1 and 10"
}
}
}
+18
View File
@@ -0,0 +1,18 @@
const z = require("zod")
module.exports = {
GET: {
headers: z.object({
"content-type": z.string()
.regex(/application\/json/i, { message: "Content-Type must be application/json" })
.optional()
}),
params: z.object({
uuid: z.string().uuid({ message: "Invalid UUID format." })
}),
error: {
code: 204,
message: "No content"
}
}
}
@@ -0,0 +1,13 @@
const z = require("zod")
module.exports = {
GET: {
params: z.object({
username: z.string().min(1, { message: "Username is required." })
}),
error: {
code: 404,
message: "Not Found"
}
}
}
+31
View File
@@ -0,0 +1,31 @@
const z = require("zod")
module.exports = {
POST: {
headers: z.object({
"content-type": z.string()
.regex(/application\/json/i, { message: "Content-Type must be application/json" })
}),
body: z.object({
agent: z.object({
name: z.string(),
version: z.number()
}).optional(),
username: z.string()
.min(3, { message: "The username must be at least 3 characters long." })
.max(16, { message: "The username must be no longer than 16 characters." }),
password: z.string()
.min(8, { message: "The password must be at least 8 characters long." })
.regex(/[A-Z]/, { message: "The password must contain a capital letter." })
.regex(/[0-9]/, { message: "The password must contain a number." }),
clientToken: z.string().optional(),
requestUser: z.boolean().optional()
}),
error: {
code: 415,
error: "Unsupported Media Type",
errorFormat: "YggdrasilError",
errorMessage: "The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method."
}
}
}
+23
View File
@@ -0,0 +1,23 @@
const z = require("zod")
module.exports = {
POST: {
headers: z.object({
"content-type": z.string()
.regex(/application\/json/i, { message: "Content-Type must be application/json" })
}),
body: z.object({
accessToken: z.string()
.min(1, { message: "Access token is required." }),
clientToken: z.string()
.min(1, { message: "Client token is required." })
}),
error: {
code: 415,
error: "Unsupported Media Type",
errorFormat: "YggdrasilError",
errorMessage: "The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method."
}
}
}
+23
View File
@@ -0,0 +1,23 @@
const z = require("zod")
module.exports = {
POST: {
headers: z.object({
"content-type": z.string()
.regex(/application\/json/i, { message: "Content-Type must be application/json" })
}),
body: z.object({
accessToken: z.string()
.min(1, { message: "Access token is required." }),
clientToken: z.string()
.min(1, { message: "Client token is required." }),
requestUser: z.boolean().optional()
}),
error: {
code: 415,
error: "Unsupported Media Type",
errorFormat: "YggdrasilError",
errorMessage: "The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method."
}
}
}
+25
View File
@@ -0,0 +1,25 @@
const z = require("zod")
module.exports = {
POST: {
headers: z.object({
"content-type": z.string()
.regex(/application\/json/i, { message: "Content-Type must be application/json" })
}),
body: z.object({
username: z.string()
.min(3, { message: "The username must be at least 3 characters long." })
.max(16, { message: "The username must be no longer than 16 characters." }),
password: z.string()
.min(8, { message: "The password must be at least 8 characters long." })
.regex(/[A-Z]/, { message: "The password must contain a capital letter." })
.regex(/[0-9]/, { message: "The password must contain a number." })
}),
error: {
code: 403,
errorFormat: "YggdrasilError",
errorName: "ForbiddenOperationException",
message: "Invalid credentials."
}
}
}
+23
View File
@@ -0,0 +1,23 @@
const z = require("zod")
module.exports = {
POST: {
headers: z.object({
"content-type": z.string()
.regex(/application\/json/i, { message: "Content-Type must be application/json" })
}),
body: z.object({
accessToken: z.string()
.min(1, { message: "Access token is required." }),
clientToken: z.string()
.optional()
}),
error: {
code: 415,
error: "Unsupported Media Type",
errorFormat: "YggdrasilError",
errorMessage: "The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method."
}
}
}
+11
View File
@@ -0,0 +1,11 @@
const z = require("zod")
module.exports = {
GET: {
query: z.object({
user: z.string().min(1),
sessionId: z.string().min(1),
serverId: z.string().min(1)
})
}
}
+10
View File
@@ -0,0 +1,10 @@
const z = require("zod")
module.exports = {
GET: {
query: z.object({
user: z.string().min(1),
serverId: z.string().min(1)
})
}
}
+16
View File
@@ -0,0 +1,16 @@
const z = require("zod")
const loginShape = {
user: z.string().min(1, { message: "Username required" }),
password: z.string().min(1, { message: "Password required" }),
version: z.union([z.string(), z.number()]).optional()
}
module.exports = {
POST: {
body: z.object(loginShape),
},
GET: {
query: z.object(loginShape)
}
}
@@ -0,0 +1,13 @@
const z = require("zod")
module.exports = {
GET: {
headers: z.object({
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
error: {
code: 401,
message: "Unauthorized"
}
}
}
@@ -0,0 +1,28 @@
const z = require("zod")
module.exports = {
DELETE: {
headers: z.object({
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
error: {
code: 401,
message: "Unauthorized"
}
},
PUT: {
headers: z.object({
"content-type": z.string()
.regex(/application\/json/i, { message: "Content-Type must be application/json" }),
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
body: z.object({
capeId: z.string().uuid({ message: "Invalid Cape UUID." })
}),
error: {
code: 400,
message: "profile does not own cape",
error: "IllegalArgumentException"
}
}
}
@@ -0,0 +1,18 @@
const z = require("zod")
module.exports = {
POST: {
headers: z.object({
"content-type": z.string()
.regex(/application\/json/i, { message: "Content-Type must be application/json" })
}),
body: z.array(z.string().trim().min(1))
.min(1, { message: "RequestPayload is an empty array." })
.max(10, { message: "RequestPayload has more than 10 elements." }),
error: {
code: 400,
error: "CONSTRAINT_VIOLATION",
errorMessage: "size must be between 1 and 10"
}
}
}
@@ -0,0 +1,13 @@
const z = require("zod")
module.exports = {
GET: {
params: z.object({
username: z.string().min(1)
}),
error: {
code: 404,
message: "Not Found"
}
}
}
@@ -0,0 +1,22 @@
const z = require("zod")
const nameSchema = z.string()
.min(1)
.max(16)
.regex(/^[a-zA-Z0-9_]+$/, { message: "Name can only contain alphanumeric characters and underscores." });
module.exports = {
PUT: {
headers: z.object({
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
params: z.object({
name: nameSchema
}),
error: {
code: 400,
error: "CONSTRAINT_VIOLATION",
errorMessage: "Invalid profile name"
}
}
}
@@ -0,0 +1,21 @@
const z = require("zod")
const nameSchema = z.string()
.min(1)
.max(16)
.regex(/^[a-zA-Z0-9_]+$/, { message: "Name can only contain alphanumeric characters and underscores." });
module.exports = {
GET: {
headers: z.object({
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
params: z.object({
name: nameSchema
}),
error: {
code: 401,
message: "Unauthorized"
}
}
}
@@ -0,0 +1,13 @@
const z = require("zod")
module.exports = {
GET: {
headers: z.object({
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
error: {
code: 401,
message: "Unauthorized"
}
}
}
@@ -0,0 +1,24 @@
const z = require("zod")
module.exports = {
POST: {
headers: z.object({
"content-type": z.string()
.regex(/application\/json/i, { message: "Content-Type must be application/json" }),
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
body: z.object({
variant: z.enum(["classic", "slim"], {
errorMap: () => ({ message: "Variant must be 'classic' or 'slim'." })
}),
url: z.string()
.url({ message: "Invalid URL format." })
.max(2048, { message: "URL is too long." })
}),
error: {
code: 400,
message: "Invalid skin URL or variant.",
error: "IllegalArgumentException"
}
}
}
@@ -0,0 +1,13 @@
const z = require("zod")
module.exports = {
DELETE: {
headers: z.object({
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
error: {
code: 401,
message: "Unauthorized"
}
}
}
@@ -0,0 +1,29 @@
const z = require("zod")
module.exports = {
GET: {
headers: z.object({
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
error: {
code: 401,
message: "Unauthorized"
}
},
POST: {
headers: z.object({
"content-type": z.string()
.regex(/application\/json/i, { message: "Content-Type must be application/json" }),
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
body: z.object({
profanityFilterPreferences: z.object({
profanityFilterOn: z.boolean({ required_error: "profanityFilterOn is required" })
})
}),
error: {
code: 400,
message: "Invalid attributes format."
}
}
}
@@ -0,0 +1,13 @@
const z = require("zod")
module.exports = {
POST: {
headers: z.object({
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
error: {
code: 401,
message: "Unauthorized"
}
}
}
@@ -0,0 +1,13 @@
const z = require("zod")
module.exports = {
GET: {
headers: z.object({
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
error: {
code: 401,
message: "Unauthorized"
}
}
}
@@ -0,0 +1,28 @@
const z = require("zod")
module.exports = {
PUT: {
headers: z.object({
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
params: z.object({
uuid: z.string().uuid({ message: "Invalid UUID." })
}),
error: {
code: 400,
message: "Invalid UUID"
}
},
DELETE: {
headers: z.object({
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
params: z.object({
uuid: z.string().uuid({ message: "Invalid UUID." })
}),
error: {
code: 400,
message: "Invalid UUID"
}
}
}
+29
View File
@@ -0,0 +1,29 @@
const z = require("zod")
module.exports = {
GET: {
headers: z.object({
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
error: {
code: 401,
message: "Unauthorized"
}
},
POST: {
headers: z.object({
"content-type": z.string()
.regex(/application\/json/i, { message: "Content-Type must be application/json" }),
"authorization": z.string().min(1, { message: "Authorization header is required." })
}),
body: z.object({
profanityFilterPreferences: z.object({
profanityFilterOn: z.boolean({ required_error: "profanityFilterOn is required" })
}).optional()
}),
error: {
code: 401,
message: "Unauthorized"
}
}
}
+25
View File
@@ -0,0 +1,25 @@
const z = require("zod")
module.exports = {
POST: {
headers: z.object({
"content-type": z.string().regex(/application\/json/i)
}),
body: z.object({
email: z.string()
.email({ message: "Invalid E-Mail format." })
.toLowerCase(),
username: z.string()
.min(3, { message: "The username must be at least 3 characters long." })
.max(16, { message: "The username must be no longer than 16 characters." }),
password: z.string()
.min(8, { message: "The password must be at least 8 characters long." })
.regex(/[A-Z]/, { message: "The password must contain a capital letter." })
.regex(/[0-9]/, { message: "The password must contain a number." })
}),
error: {
code: 422,
message: "Invalid request data"
}
}
}
@@ -0,0 +1,19 @@
const z = require("zod")
module.exports = {
GET: {
query: z.object({
username: z.string()
.min(3)
.max(16),
serverId: z.string()
.min(1),
ip: z.string()
.optional()
}),
error: {
code: 204,
message: "Ignored"
}
}
}
@@ -0,0 +1,22 @@
const z = require("zod")
module.exports = {
POST: {
body: z.object({
accessToken: z.string()
.min(1, { message: "Access Token is required." }),
selectedProfile: z.string()
.length(32, { message: "Selected Profile must be a valid UUID without dashes." })
.regex(/^[0-9a-fA-F]+$/, { message: "Selected Profile must be hexadecimal." }),
serverId: z.string()
.min(1, { message: "Server ID is required." })
.max(42, { message: "Server ID is too long." })
}),
error: {
code: 400,
message: "Missing or invalid parameters.",
errorFormat: "SessionError",
errorName: "Forbidden"
}
}
}
@@ -0,0 +1,16 @@
const z = require("zod")
module.exports = {
GET: {
params: z.object({
uuid: z.string().length(32).regex(/^[0-9a-fA-F]+$/, { message: "Invalid UUID (no dashes expected)." })
}),
query: z.object({
unsigned: z.enum(["true", "false"]).optional()
}),
error: {
code: 204,
message: "No content (UUID not found)"
}
}
}