feat: Add new settings page with Apple-style UI, OpenRouter AI integration, and Mary v4 analysis.

This commit is contained in:
Michael committed 2026-02-27 10:02:23 +01:00
1 parent f352594b19
commit c95eb0ecb6
7 files changed
+221 -48

No files matched your search

+9
View File
@@ -6,6 +6,10 @@ import { db } from "@/db";
import { aiSupplierContext } from "@/db/schema";
import { eq } from "drizzle-orm";
// Limite max acceptable pour la route (Node.js self-hosted).
// Evite que le process tourne indéfiniment en cas de deadlock.
export const maxDuration = 55;
export async function POST(req: NextRequest) {
const config = await getSavedDatabaseConfig();
const apiKey = process.env.OPENROUTER_API_KEY || config?.openRouterKey;
@@ -42,6 +46,11 @@ export async function POST(req: NextRequest) {
if (err instanceof Error && err.message === "rate_limited") {
return NextResponse.json({ error: "rate_limited", retryAfter: 30 }, { status: 429 });
}
// Timeout explicite déclenché par l'AbortController du client
if (err instanceof Error && err.message === "timeout") {
console.warn(`[AI] Timeout for product analysis — OpenRouter too slow.`);
return NextResponse.json({ error: "timeout", retryAfter: 5 }, { status: 504 });
}
const msg = err instanceof Error ? err.message : "Unknown error";
return NextResponse.json({ error: msg }, { status: 500 });
}