import { NextResponse } from "next/server"; import { getCurrentSession } from "@/lib/session"; import { searchSpecies } from "@/modules/garden/server/species-lookup"; export async function GET(request: Request) { try { await getCurrentSession(); } catch { return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); } const { searchParams } = new URL(request.url); const q = searchParams.get("q") ?? ""; const results = await searchSpecies(q); return NextResponse.json(results); }