- perenual species lookup with 24h db cache (api key optional) - /api/garden/species-search route handler - createPlant / updatePlant / deletePlant server actions - addPlantImage / removePlantImage / setPrimaryImage actions (max 10) - listPlants query grouped by container with last-watered subquery - getPlant query with care log summary and active schedules - plant-form client component with species autofill and image upload - plant-list server component grouped by container with unassigned bucket - plant-detail client component with info/gallery/care tabs - species-search debounced combobox component - /garden/plants/new, /[id], /[id]/edit pages - garden.plant entity registered with search and share support - /garden page updated to containers/plants tabs (default: containers)
18 lines
516 B
TypeScript
18 lines
516 B
TypeScript
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);
|
|
}
|