🎉 init

This commit is contained in:
2026-07-01 15:43:18 +02:00
commit 2f492c55be
64 changed files with 11645 additions and 0 deletions
@@ -0,0 +1,29 @@
import { and, eq } from 'drizzle-orm'
import { isValidPaymentLink } from '../../../../../shared/utils/paymentLink'
import { useDb } from '../../../../database/client'
import { participants } from '../../../../database/schema'
export default defineEventHandler(async (event) => {
const slug = getRouterParam(event, 'slug')!
const id = Number(getRouterParam(event, 'id'))
await getPotOrThrow(slug)
const body = await readBody(event)
const paymentLink = typeof body?.paymentLink === 'string' ? body.paymentLink.trim() : ''
if (paymentLink && !isValidPaymentLink(paymentLink)) {
throw createError({ statusCode: 400, statusMessage: 'paymentLink must be a valid http(s) URL' })
}
const db = useDb()
const [existing] = await db.select().from(participants).where(and(eq(participants.id, id), eq(participants.potSlug, slug)))
if (!existing) {
throw createError({ statusCode: 404, statusMessage: 'Participant not found' })
}
const [updated] = await db.update(participants)
.set({ paymentLink: paymentLink || null })
.where(eq(participants.id, id))
.returning()
return updated
})