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,15 +60,23 @@ export async function POST(request: Request) {
|
|||
return Response.json({ error: "QR code is not a valid Mii QR code" }, { status: 400 });
|
||||
|
||||
// Convert to Mii class
|
||||
let mii: Mii;
|
||||
let tomodachiLifeMii: TomodachiLifeMii;
|
||||
|
||||
try {
|
||||
const buffer = Buffer.from(result);
|
||||
const mii = new Mii(buffer);
|
||||
const tomodachiLifeMii = TomodachiLifeMii.fromBytes(qrBytes);
|
||||
mii = new Mii(buffer);
|
||||
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
|
||||
const miiRecord = await prisma.mii.create({
|
||||
|
|
|
|||
Loading…
Reference in a new issue