55fb221faa
Each integration card now has a Test button that re-runs its connectivity check on demand and updates the badge in place. - Refactors checkIntegrationStatus into checkIntegration(name) so a single integration can be tested without firing the others. - Adds POST /api/settings/test for the on-demand check. - Replaces the "key exists ⇒ connected" placeholder for Tavily, Gemini, and Nextdoor with real API calls (Tavily search, Gemini models list, Nextdoor advertiser fetch). 401/403 surface as "Invalid API key" / "Token expired or invalid" so a stale credential is obvious instead of pretending to be healthy. - Fixes Postiz auth header (was Bearer, the rest of the codebase passes the API key bare — matches lib/postiz.ts now). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
20 lines
699 B
TypeScript
20 lines
699 B
TypeScript
import { auth } from "@/lib/auth";
|
|
import { checkIntegration, type IntegrationName } from "@/lib/settings";
|
|
|
|
const VALID: IntegrationName[] = ["claude", "postiz", "tavily", "gemini", "nextdoor"];
|
|
|
|
export async function POST(request: Request) {
|
|
const session = await auth();
|
|
if (!session) return new Response("Unauthorized", { status: 401 });
|
|
|
|
const body = await request.json().catch(() => ({}));
|
|
const name = body?.integration as IntegrationName | undefined;
|
|
|
|
if (!name || !VALID.includes(name)) {
|
|
return Response.json({ error: "integration must be one of: " + VALID.join(", ") }, { status: 400 });
|
|
}
|
|
|
|
const status = await checkIntegration(name);
|
|
return Response.json(status);
|
|
}
|