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:
9
schemas/admin/admin/cosmetics/capes/[hash].js
Normal file
9
schemas/admin/admin/cosmetics/capes/[hash].js
Normal file
@@ -0,0 +1,9 @@
|
||||
const z = require("zod")
|
||||
|
||||
module.exports = {
|
||||
DELETE: {
|
||||
query: z.object({
|
||||
hash: z.string().length(64)
|
||||
})
|
||||
}
|
||||
}
|
||||
9
schemas/admin/ban/[uuid]/actions.js
Normal file
9
schemas/admin/ban/[uuid]/actions.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const z = require("zod")
|
||||
|
||||
module.exports = {
|
||||
GET: {
|
||||
query: z.object({
|
||||
uuid: z.string().uuid()
|
||||
})
|
||||
}
|
||||
}
|
||||
9
schemas/admin/ban/[uuid]/history.js
Normal file
9
schemas/admin/ban/[uuid]/history.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const z = require("zod")
|
||||
|
||||
module.exports = {
|
||||
GET: {
|
||||
query: z.object({
|
||||
uuid: z.string().uuid()
|
||||
})
|
||||
}
|
||||
}
|
||||
26
schemas/admin/ban/[uuid]/index.js
Normal file
26
schemas/admin/ban/[uuid]/index.js
Normal 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
schemas/admin/players/password/[uuid].js
Normal file
12
schemas/admin/players/password/[uuid].js
Normal 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." }),
|
||||
})
|
||||
}
|
||||
}
|
||||
16
schemas/admin/players/textures/cape/[uuid]/[hash].js
Normal file
16
schemas/admin/players/textures/cape/[uuid]/[hash].js
Normal file
@@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
18
schemas/api/minecraft/profile/lookup/bulk/byname.js
Normal file
18
schemas/api/minecraft/profile/lookup/bulk/byname.js
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
13
schemas/api/profile/lookup/name/[username].js
Normal file
13
schemas/api/profile/lookup/name/[username].js
Normal file
@@ -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
schemas/api/profiles/minecraft.js
Normal file
18
schemas/api/profiles/minecraft.js
Normal 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
schemas/api/user/profiles/[uuid]/names.js
Normal file
18
schemas/api/user/profiles/[uuid]/names.js
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
13
schemas/api/users/profiles/minecraft/[username].js
Normal file
13
schemas/api/users/profiles/minecraft/[username].js
Normal file
@@ -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
schemas/authserver/authenticate.js
Normal file
31
schemas/authserver/authenticate.js
Normal 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
schemas/authserver/invalidate.js
Normal file
23
schemas/authserver/invalidate.js
Normal 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
schemas/authserver/refresh.js
Normal file
23
schemas/authserver/refresh.js
Normal 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
schemas/authserver/signout.js
Normal file
25
schemas/authserver/signout.js
Normal 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
schemas/authserver/validate.js
Normal file
23
schemas/authserver/validate.js
Normal 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
schemas/legacy/joinserver.js
Normal file
11
schemas/legacy/joinserver.js
Normal 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
schemas/legacy/legacy/checkserver.js
Normal file
10
schemas/legacy/legacy/checkserver.js
Normal 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
schemas/legacy/login.js
Normal file
16
schemas/legacy/login.js
Normal 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)
|
||||
}
|
||||
}
|
||||
13
schemas/minecraftservices/minecraft/profile.js
Normal file
13
schemas/minecraftservices/minecraft/profile.js
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
28
schemas/minecraftservices/minecraft/profile/capes/active.js
Normal file
28
schemas/minecraftservices/minecraft/profile/capes/active.js
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
22
schemas/minecraftservices/minecraft/profile/name/[name].js
Normal file
22
schemas/minecraftservices/minecraft/profile/name/[name].js
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
13
schemas/minecraftservices/minecraft/profile/namechange.js
Normal file
13
schemas/minecraftservices/minecraft/profile/namechange.js
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
24
schemas/minecraftservices/minecraft/profile/skins.js
Normal file
24
schemas/minecraftservices/minecraft/profile/skins.js
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
13
schemas/minecraftservices/minecraft/profile/skins/active.js
Normal file
13
schemas/minecraftservices/minecraft/profile/skins/active.js
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
29
schemas/minecraftservices/player/attributes.js
Normal file
29
schemas/minecraftservices/player/attributes.js
Normal 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" })
|
||||
})
|
||||
}),
|
||||
error: {
|
||||
code: 400,
|
||||
message: "Invalid attributes format."
|
||||
}
|
||||
}
|
||||
}
|
||||
13
schemas/minecraftservices/player/certificates.js
Normal file
13
schemas/minecraftservices/player/certificates.js
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
13
schemas/minecraftservices/privacy/blocklist.js
Normal file
13
schemas/minecraftservices/privacy/blocklist.js
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
28
schemas/minecraftservices/privacy/blocklist/[uuid].js
Normal file
28
schemas/minecraftservices/privacy/blocklist/[uuid].js
Normal file
@@ -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
schemas/minecraftservices/privileges.js
Normal file
29
schemas/minecraftservices/privileges.js
Normal 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
schemas/register.js
Normal file
25
schemas/register.js
Normal 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
19
schemas/sessionsserver/session/minecraft/hasJoined.js
Normal file
19
schemas/sessionsserver/session/minecraft/hasJoined.js
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
22
schemas/sessionsserver/session/minecraft/join.js
Normal file
22
schemas/sessionsserver/session/minecraft/join.js
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
16
schemas/sessionsserver/session/minecraft/profile/[uuid].js
Normal file
16
schemas/sessionsserver/session/minecraft/profile/[uuid].js
Normal file
@@ -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)"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user