Download src/app/api/sync/route.ts from HonzaH/Letschat: direct link, hf CLI and curl.
- Browser
- Download file 702 Bytes
-
https://huggingface.co/spaces/HonzaH/Letschat/resolve/main/src/app/api/sync/route.ts
- Command line
-
hf download hf://spaces/HonzaH/Letschat/src/app/api/sync/route.ts
-
curl -L -o route.ts https://huggingface.co/spaces/HonzaH/Letschat/resolve/main/src/app/api/sync/route.ts
702 Bytes
| 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 }) | |
| } | |
| } | |