import { sendJson } from '../http.js';
import { getCompositeProductList } from '../queries/composite-product-list.js';

export const method = 'GET';
export const path = '/v1/productcomposite';

export async function handle(_req, res, { url }) {
  const cursor = Number(url.searchParams.get('lastChangedCompositeProduct')) || 0;
  const limit = Number(url.searchParams.get('limit')) || 100;

  const composites = await getCompositeProductList({ cursor, limit });

  return sendJson(res, 200, composites);
}
