feat: add hub

This commit is contained in:
huaqo
2026-10-03 23:57:41 +02:00
parent 5452f72087
commit fb7b560696
52 changed files with 290 additions and 162 deletions
@@ -9,13 +9,13 @@ export default defineEventHandler(async (event) => {
const id = Number(getRouterParam(event, 'id'))
const body = coverSchema.safeParse(await readBody(event))
if (!Number.isInteger(id) || !body.success) {
throw createError({ statusCode: 400, statusMessage: 'Invalid cover' })
throw createError({ statusCode: 400, statusMessage: 'Ungültiges Cover' })
}
const table = wishlistTable(event)
const rows = await listRows<WishlistRow>(event, table)
const row = rows.find(row => row.id === id)
if (!row) throw createError({ statusCode: 404, statusMessage: 'No such book' })
if (!row) throw createError({ statusCode: 404, statusMessage: 'Buch nicht gefunden' })
if (row.cover) return toWishlistBook(row)
return toWishlistBook(await updateRow<WishlistRow>(event, table, id, { cover: body.data.cover }))