mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-12 02:02:13 +03:00
feat(ui): ProviderIcon component with @lobehub/icons + PNG fallback (#529) - 130+ providers covered by Lobehub SVG components via LobehubErrorBoundary - Falls back to existing /providers/{id}.png, then generic icon - Replaces manual img state machine in ProviderCard + ApiKeyProviderCard feat(scheduler): modelSyncScheduler — 24h model list auto-update (#488) - Syncs 16 major providers every 24h (MODEL_SYNC_INTERVAL_HOURS configurable) - Wired into POST /api/sync/initialize startup hook fix(oauth): Gemini CLI — clear error when client_secret missing in Docker (#537)
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import initializeCloudSync from "@/shared/services/initializeCloudSync";
|
|
import { startModelSyncScheduler } from "@/shared/services/modelSyncScheduler";
|
|
|
|
let syncInitialized = false;
|
|
let modelSyncInitialized = false;
|
|
|
|
// POST /api/sync/initialize - Initialize cloud sync scheduler
|
|
export async function POST(request) {
|
|
try {
|
|
if (syncInitialized) {
|
|
return NextResponse.json({
|
|
message: "Cloud sync already initialized",
|
|
});
|
|
}
|
|
|
|
await initializeCloudSync();
|
|
syncInitialized = true;
|
|
|
|
// (#488) Start model auto-sync scheduler (24h, configurable via MODEL_SYNC_INTERVAL_HOURS)
|
|
if (!modelSyncInitialized) {
|
|
const origin = request.headers.get("origin") || "http://localhost:20128";
|
|
startModelSyncScheduler(origin);
|
|
modelSyncInitialized = true;
|
|
}
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
message: "Cloud sync initialized successfully",
|
|
modelSyncEnabled: true,
|
|
});
|
|
} catch (error) {
|
|
console.log("Error initializing cloud sync:", error);
|
|
return NextResponse.json(
|
|
{
|
|
error: "Failed to initialize cloud sync",
|
|
},
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|
|
|
|
// GET /api/sync/status - Check sync initialization status
|
|
export async function GET(request) {
|
|
return NextResponse.json({
|
|
initialized: syncInitialized,
|
|
modelSyncInitialized,
|
|
message: syncInitialized ? "Cloud sync is running" : "Cloud sync not initialized",
|
|
});
|
|
}
|