bdf9cupe3: Add expert text search and category browse to the left column

This commit is contained in:
2026-10-19 17:33:43 -06:00
parent b97a77471b
commit 5b70bbfefa
7 changed files with 463 additions and 2 deletions
+21
View File
@@ -0,0 +1,21 @@
import { NextResponse } from "next/server";
import { browseCategory, searchExperts } from "@/lib/experts-search";
// GET /api/experts/search?q=<text> or ?category=<name>
// Same-origin proxy for Minnect's PUBLIC expert list. EXPERTS ONLY: it never
// calls a user-search endpoint. Public fields only. No session needed.
// Upstream failure -> 502 { error: "experts_unavailable" }.
export const runtime = "nodejs";
export async function GET(req: Request) {
const url = new URL(req.url);
const q = (url.searchParams.get("q") ?? "").trim().slice(0, 80);
const category = (url.searchParams.get("category") ?? "").trim().slice(0, 80);
if (!q && !category) return NextResponse.json({ experts: [] });
const result = q ? await searchExperts(q) : await browseCategory(category);
if (!result.ok) {
return NextResponse.json({ error: result.error }, { status: result.status });
}
return NextResponse.json({ experts: result.experts });
}