// POST /api/tasks (web) — create an Idle task with a server-generated GUID. export default defineEventHandler(async (event) => { const body = await readBody(event); const title = typeof body?.title === "string" ? body.title.trim() : ""; const listId = body?.listId; if (!title || typeof listId !== "string") { throw createError({ statusCode: 400, statusMessage: "title and listId are required" }); } const description = typeof body?.description === "string" && body.description.trim() ? body.description : null; const sql = getSql(); if (!(await listExists(sql, listId))) { throw createError({ statusCode: 404, statusMessage: "list not found" }); } const row = await createWebTask(sql, { listId, title, description }); setResponseStatus(event, 201); return toTaskDto(row); });