Add schema to realtime route.

This commit is contained in:
Mike Cao committed 2026-06-02 22:07:46 -07:00
1 parent 46819a4443
commit 44c6b4427f
1 file changed
+9 -1
+9 -1
View File
@@ -1,15 +1,23 @@
import { startOfMinute, subMinutes } from 'date-fns';
import { z } from 'zod';
import { REALTIME_RANGE } from '@/lib/constants';
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
import { canViewWebsiteSection } from '@/permissions';
import { filterParams, timezoneParam, unitParam } from '@/lib/schema';
import { getRealtimeData } from '@/queries/sql';
export async function GET(
request: Request,
{ params }: { params: Promise<{ websiteId: string }> },
) {
const { auth, query, error } = await parseRequest(request);
const schema = z.object({
timezone: timezoneParam.optional(),
unit: unitParam.optional(),
...filterParams,
});
const { auth, query, error } = await parseRequest(request, schema);
if (error) {
return error();