import { NextResponse } from "next/server";
import { apiHandler } from "@/lib/api";
import { getInputTips } from "@/lib/amap";

export const GET = apiHandler(async (req) => {
  const keywords = req.nextUrl.searchParams.get("keywords")?.trim();
  if (!keywords) return NextResponse.json([]);

  const location = req.nextUrl.searchParams.get("location") || undefined;
  const suggestions = await getInputTips({ keywords, location });
  return NextResponse.json(suggestions);
});
