Added some error message handling and added basic info about functionality on ui

This commit is contained in:
Tom
2024-01-06 20:17:04 +00:00
parent 0f7fb11f4e
commit 68df045c54
13 changed files with 232 additions and 93 deletions

View File

@ -19,7 +19,7 @@ export async function GET(req: Request) {
const voice = voices.find(v => v.value == new String(u?.ttsDefaultVoice))
return NextResponse.json(voice);
} catch (error) {
console.log("[TTS/FILTER/USER]", error);
console.log("[TTS/FILTER/DEFAULT]", error);
return new NextResponse("Internal Error", { status: 500 });
}
}
@ -32,11 +32,9 @@ export async function POST(req: Request) {
}
const { voice } = await req.json();
console.log(voice)
if (!voice || !voices.map(v => v.label.toLowerCase()).includes(voice.toLowerCase())) return new NextResponse("Bad Request", { status: 400 });
const v = voices.find(v => v.label.toLowerCase() == voice.toLowerCase())
if (v == null)
return new NextResponse("Bad Request", { status: 400 });
await db.user.update({
where: {
@ -49,7 +47,7 @@ export async function POST(req: Request) {
return new NextResponse("", { status: 200 });
} catch (error) {
console.log("[TTS/FILTER/USER]", error);
console.log("[TTS/FILTER/DEFAULT]", error);
return new NextResponse("Internal Error", { status: 500 });
}
}