in src/app/api/share/route.ts [6:20]
export async function POST(req: NextRequest) {
try {
const { input, prompt, voice } = await req.json();
const clippedInput = input.slice(0, MAX_INPUT_LENGTH);
const clippedPrompt = prompt.slice(0, MAX_PROMPT_LENGTH);
const id = crypto.randomUUID();
await sql`INSERT INTO shares (id, input, prompt, voice) VALUES (${id}, ${
clippedInput ?? ""
}, ${clippedPrompt ?? ""}, ${voice ?? ""});`;
return Response.json({ id });
} catch (err) {
console.error("Error storing share params:", err);
return new Response("An error ocurred.", { status: 500 });
}
}