Task 4.2: Add default data seeding on new user creation

Create seedUserDefaults() helper in src/lib/db/seed-user-defaults.ts
that inserts default annotation_types (break_up, break_down, line) and
default span_label_types (bull_flag, bear_flag, etc.) scoped to a
given user_id. Call it from POST /api/auth/register after user insert
and from src/auth.ts Google signIn callback after new Google user creation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marko Djordjevic 2026-02-20 10:16:55 +01:00
parent 9a5e325632
commit 10e4ec8648
4 changed files with 61 additions and 3 deletions

View file

@ -3,6 +3,7 @@ import bcryptjs from 'bcryptjs';
import { eq } from 'drizzle-orm';
import { db } from '@/lib/db';
import { users } from '@/lib/db/schema';
import { seedUserDefaults } from '@/lib/db/seed-user-defaults';
export async function POST(request: NextRequest) {
let body: unknown;
@ -57,6 +58,9 @@ export async function POST(request: NextRequest) {
})
.returning({ id: users.id, email: users.email, name: users.name });
// Seed default annotation types and span label types for the new user
await seedUserDefaults(newUser.id);
return NextResponse.json(
{ id: newUser.id, email: newUser.email, name: newUser.name },
{ status: 201 }