20 lines
633 B
TypeScript
20 lines
633 B
TypeScript
import type {NextRequest} from 'next/server';
|
|
import {ok, parseQuery, requireApiSession, simulate, wantsEmpty} from '@/shared/services/apiRoute';
|
|
import {buildBriefing} from '@/features/dashboard/mock/briefing.mock';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
const EMPTY = {summary: '', alerts: [], tasks: []};
|
|
|
|
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) ? EMPTY : buildBriefing(q.storeId, q.range, q.nowMs),
|
|
q,
|
|
);
|
|
}
|