add group creation

This commit is contained in:
2026-01-07 10:25:33 +01:00
parent 090b3c10d1
commit 624e62822c
12 changed files with 330 additions and 94 deletions

View File

@@ -14,7 +14,6 @@ const server = serve({
console.log('Received request for user:', mail);
const user = await db.getUserByMail(mail);
console.log('Fetching user with mail:', mail, 'Result:', user);
if (!user) return new Response(JSON.stringify({ error: 'User not found' }), { status: 404 });
return new Response(JSON.stringify(user), { headers: { 'Content-Type': 'application/json' } });
},
@@ -37,7 +36,6 @@ const server = serve({
console.log('Received request for group:', code);
const group = await db.getGroupByCode(code);
console.log('Fetching group with ID:', code, 'Result:', group);
if (!group) return new Response(JSON.stringify({ error: 'Group not found' }), { status: 404 });
return new Response(JSON.stringify(group), { headers: { 'Content-Type': 'application/json' } });
},
@@ -46,7 +44,7 @@ const server = serve({
try {
const { name, mail } = await req.json() as { name: string; mail: string };
console.log('Received request to create group with name:', name, 'and mail:', mail);
const response = db.createGroup({ name, mail });
const response = await db.createGroup({ name, mail });
return new Response(JSON.stringify(response), { headers: { 'Content-Type': 'application/json' } });
} catch (err) {
console.error('Error creating group:', err);