15 lines
569 B
TypeScript
15 lines
569 B
TypeScript
import type {NextRequest} from 'next/server';
|
|
import {ok, parseQuery, requireApiSession, simulate, wantsEmpty} from '@/shared/services/apiRoute';
|
|
import {buildTimeseries} from '@/features/dashboard/mock/dashboard.mock';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
export async function GET(req: NextRequest) {
|
|
const denied = await requireApiSession();
|
|
if (denied) return denied;
|
|
const q = parseQuery(req);
|
|
const simulated = await simulate(q);
|
|
if (simulated) return simulated;
|
|
return ok(wantsEmpty(q) ? [] : buildTimeseries(q.range, q.storeId, q.nowMs), q);
|
|
}
|