import type {NextRequest} from 'next/server';
import {ok, parseQuery, simulate, wantsEmpty} from '@/lib/api/server';
import {buildStores} from '@/lib/mock/stores';

export const dynamic = 'force-dynamic';

export async function GET(req: NextRequest) {
  const q = parseQuery(req);
  const simulated = await simulate(q);
  if (simulated) return simulated;
  return ok(wantsEmpty(q) ? [] : buildStores(q.range, q.nowMs), q);
}
