import { sendJson } from '../http.js';
import { getCustomerGroupList } from '../queries/customer-groups.js';

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

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

  const customerGroups = await getCustomerGroupList({ cursor });

  return sendJson(res, 200, customerGroups);
}
