File size: 702 Bytes
017e02b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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 })
}
}
|