import { NextResponse, NextRequest } from 'next/server' import { prisma } from '@/lib/db' import { getAuth } from '@clerk/nextjs/server' export const runtime = 'nodejs' export async function POST(request: NextRequest) { try { const { userId } = await getAuth(request) if (!userId) { return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) } const body = await request.json() const { verseId, color } = body if (!verseId || !['yellow', 'orange', 'pink', 'blue'].includes(color)) { return NextResponse.json({ error: 'Invalid input' }, { status: 400 }) } const highlight = await prisma.userHighlight.create({ data: { userId, verseId, color, createdAt: new Date(), updatedAt: new Date() } }) return NextResponse.json({ id: highlight.id, verseId: highlight.verseId, color: highlight.color, createdAt: highlight.createdAt.getTime(), updatedAt: highlight.updatedAt.getTime(), syncStatus: 'synced' }) } catch (error) { console.error('Error creating highlight:', error) return NextResponse.json( { error: 'Failed to create highlight' }, { status: 500 } ) } }