🐛 fix typecheck and cleanup imports
tinyedge/deploy Deployed by TinyEdge

This commit is contained in:
2026-08-07 12:57:45 +02:00
parent c6b78d4665
commit 67727f96ab
17 changed files with 1790 additions and 1352 deletions
@@ -0,0 +1,25 @@
import { and, eq } from 'drizzle-orm'
import { useDb } from '~~/server/database/client'
import { expenseParticipants, expenses, participants } from '~~/server/database/schema'
export default defineEventHandler(async (event) => {
const slug = getRouterParam(event, 'slug')!
const id = Number(getRouterParam(event, 'id'))
await getPotOrThrow(slug)
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 [asPayer] = await db.select().from(expenses).where(eq(expenses.payerId, id)).limit(1)
const [asSplit] = await db.select().from(expenseParticipants).where(eq(expenseParticipants.participantId, id)).limit(1)
if (asPayer || asSplit) {
throw createError({ statusCode: 409, statusMessage: 'Cannot remove a participant with expenses or payments' })
}
await db.delete(participants).where(eq(participants.id, id))
return { success: true }
})
@@ -1,7 +1,7 @@
import { and, eq } from 'drizzle-orm'
import { isValidPaymentLink } from '../../../../../shared/utils/paymentLink'
import { useDb } from '../../../../database/client'
import { participants } from '../../../../database/schema'
import { isValidPaymentLink } from '~~/shared/utils/paymentLink'
import { useDb } from '~~/server/database/client'
import { participants } from '~~/server/database/schema'
export default defineEventHandler(async (event) => {
const slug = getRouterParam(event, 'slug')!