Updated the skin upload schema to accept both JSON and multipart/form-data content types, and to allow requests without a URL. Simplified the texture storage path in userService.js by removing subdirectory partitioning based on hash.
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
const z = require("zod")
|
|
|
|
module.exports = {
|
|
POST: {
|
|
headers: z.object({
|
|
"content-type": z.string()
|
|
.regex(/application\/json|multipart\/form-data/i, {
|
|
message: "Content-Type must be application/json or multipart/form-data"
|
|
}),
|
|
"authorization": z.string().min(1, { message: "Authorization header is required." })
|
|
}),
|
|
body: z.union([
|
|
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." })
|
|
}),
|
|
z.object({
|
|
variant: z.enum(["classic", "slim"], {
|
|
errorMap: () => ({ message: "Variant must be 'classic' or 'slim'." })
|
|
}),
|
|
})
|
|
]),
|
|
error: {
|
|
code: 400,
|
|
message: "Invalid skin data, URL or variant.",
|
|
error: "IllegalArgumentException"
|
|
}
|
|
}
|
|
} |