UI overhault
This commit is contained in:
22
app/api/sync/route.ts
Normal file
22
app/api/sync/route.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { authenticate } from '@/app/lib/utils';
|
||||
import { syncAllDomains } from '@/app/lib/sync';
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
if (!authenticate(req)) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
|
||||
try {
|
||||
// Start sync in background (don't wait for completion)
|
||||
syncAllDomains().catch(err => {
|
||||
console.error('Sync failed:', err);
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: 'Sync started in background'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error starting sync:', error);
|
||||
return NextResponse.json({ error: 'Failed to start sync' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user