🐛 add env to useDb and apply prettier
tinyedge/deploy Deployed by TinyEdge

This commit is contained in:
2026-08-07 13:28:26 +02:00
parent 67727f96ab
commit cbe1b42f6e
54 changed files with 5492 additions and 2406 deletions
+14 -11
View File
@@ -1,17 +1,20 @@
import { useDb } from '~~/server/database/client'
import { participants } from '~~/server/database/schema'
import { useDb } from '~~/server/database/client';
import { participants } from '~~/server/database/schema';
export default defineEventHandler(async (event) => {
const slug = getRouterParam(event, 'slug')!
await getPotOrThrow(slug)
const slug = getRouterParam(event, 'slug')!;
await getPotOrThrow(slug);
const body = await readBody(event)
const name = typeof body?.name === 'string' ? body.name.trim() : ''
const body = await readBody(event);
const name = typeof body?.name === 'string' ? body.name.trim() : '';
if (!name) {
throw createError({ statusCode: 400, statusMessage: 'name is required' })
throw createError({ statusCode: 400, statusMessage: 'name is required' });
}
const db = useDb()
const [participant] = await db.insert(participants).values({ potSlug: slug, name }).returning()
return participant
})
const db = useDb(event);
const [participant] = await db
.insert(participants)
.values({ potSlug: slug, name })
.returning();
return participant;
});