// madarX OS — Marketplace REST surface (Phase 1).
//
// GET /api/marketplace?kind=&category=&q=
//   Returns the unified MarketplaceItem array. Mirrors what the /marketplace
//   page renders server-side. kind=agent is rejected with 400 (Phase 1 boundary).

import { listMarketplaceItems } from '../../../lib/marketplace.js';

export const dynamic = 'force-dynamic';
export const runtime = 'nodejs';

export async function GET(request) {
  const url = new URL(request.url);
  const kind = url.searchParams.get('kind') || undefined;
  const category = url.searchParams.get('category') || undefined;
  const q = url.searchParams.get('q') || undefined;

  const items = listMarketplaceItems({ kind, category, query: q });
  return Response.json({ items });
}
