16 lines
512 B
TypeScript
16 lines
512 B
TypeScript
// PUT /api/lists (desktop) — full-replace catalog. Upsert all supplied; delete the rest.
|
|
export default defineEventHandler(async (event) => {
|
|
const body = await readBody(event);
|
|
if (
|
|
!Array.isArray(body) ||
|
|
body.some((l) => typeof l?.id !== "string" || typeof l?.name !== "string")
|
|
) {
|
|
throw createError({ statusCode: 400, statusMessage: "expected [{ id, name }]" });
|
|
}
|
|
await replaceLists(
|
|
getSql(),
|
|
body.map((l) => ({ id: l.id, name: l.name })),
|
|
);
|
|
return { ok: true };
|
|
});
|