fix: wrap mii classes in try/catch in submit route
This commit is contained in:
parent
37af539911
commit
c2e74c89bb
1 changed files with 15 additions and 7 deletions
|
|
@ -60,14 +60,22 @@ export async function POST(request: Request) {
|
||||||
return Response.json({ error: "QR code is not a valid Mii QR code" }, { status: 400 });
|
return Response.json({ error: "QR code is not a valid Mii QR code" }, { status: 400 });
|
||||||
|
|
||||||
// Convert to Mii class
|
// Convert to Mii class
|
||||||
const buffer = Buffer.from(result);
|
let mii: Mii;
|
||||||
const mii = new Mii(buffer);
|
let tomodachiLifeMii: TomodachiLifeMii;
|
||||||
const tomodachiLifeMii = TomodachiLifeMii.fromBytes(qrBytes);
|
|
||||||
|
|
||||||
if (tomodachiLifeMii.hairDyeEnabled) {
|
try {
|
||||||
mii.hairColor = tomodachiLifeMii.studioHairColor;
|
const buffer = Buffer.from(result);
|
||||||
mii.eyebrowColor = tomodachiLifeMii.studioHairColor;
|
mii = new Mii(buffer);
|
||||||
mii.facialHairColor = tomodachiLifeMii.studioHairColor;
|
tomodachiLifeMii = TomodachiLifeMii.fromBytes(qrBytes);
|
||||||
|
|
||||||
|
if (tomodachiLifeMii.hairDyeEnabled) {
|
||||||
|
mii.hairColor = tomodachiLifeMii.studioHairColor;
|
||||||
|
mii.eyebrowColor = tomodachiLifeMii.studioHairColor;
|
||||||
|
mii.facialHairColor = tomodachiLifeMii.studioHairColor;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("Mii data is not valid:", error);
|
||||||
|
return Response.json({ error: "Mii data is not valid" }, { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Mii in database
|
// Create Mii in database
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue