278e57354c
- Monthly spend chart with category breakdown drill-down - Merchant frequency and spend analytics with per-merchant history - Subscription detection and recurring charge tracking - Fee and interest analytics endpoint - Expanded category list with formatCategory display helper
17 lines
560 B
TypeScript
17 lines
560 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { getMerchantSuggestions, getBankNames } from "@/lib/queries";
|
|
|
|
export async function GET(req: NextRequest) {
|
|
const search = req.nextUrl.searchParams.get("search");
|
|
const type = req.nextUrl.searchParams.get("type");
|
|
|
|
if (type === "banks") {
|
|
const banks = await getBankNames();
|
|
return NextResponse.json(banks);
|
|
}
|
|
|
|
if (!search) return NextResponse.json([]);
|
|
const merchants = await getMerchantSuggestions(search);
|
|
return NextResponse.json(merchants.map((m) => m.merchant));
|
|
}
|