| import { NextRequest, NextResponse } from 'next/server' | |
| import { syncLocalToSupabase } from 'lib/persistence' | |
| export async function POST(request: NextRequest) { | |
| try { | |
| const body = await request.json().catch(() => ({})) | |
| const action = body?.action || request.nextUrl.searchParams.get('action') | |
| if (action === 'local') { | |
| const res = await syncLocalToSupabase() | |
| return NextResponse.json({ ok: true, synced: res?.synced ?? 0 }) | |
| } | |
| return NextResponse.json({ ok: false, error: 'unknown action' }, { status: 400 }) | |
| } catch (e) { | |
| console.error('[api/sync] error', e) | |
| return NextResponse.json({ ok: false, error: String(e) }, { status: 500 }) | |
| } | |
| } | |