Add session join schema and enhance error serialization

Introduces a Zod schema for the Minecraft session join endpoint, validating accessToken, selectedProfile, and serverId. Updates ValidationError to support serialization via YggdrasilError and SessionError for improved error formatting.
This commit is contained in:
2025-12-24 04:54:53 +01:00
parent 2519d8078a
commit 3d0f5c54af
2 changed files with 41 additions and 6 deletions

View 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"
}
}
}