From a049fbb5b0b2e8c3325f058bea26050c849bd91f Mon Sep 17 00:00:00 2001 From: AymanAlSuleihi Date: Fri, 9 Jan 2026 23:41:16 +0000 Subject: [PATCH] Update compare parameter to use enum for valid values --- src/app/api/websites/[websiteId]/stats/route.ts | 2 +- src/lib/schema.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/api/websites/[websiteId]/stats/route.ts b/src/app/api/websites/[websiteId]/stats/route.ts index 12492537..b7177b5d 100644 --- a/src/app/api/websites/[websiteId]/stats/route.ts +++ b/src/app/api/websites/[websiteId]/stats/route.ts @@ -31,7 +31,7 @@ export async function GET( const data = await getWebsiteStats(websiteId, filters); - const compare = filters.compare === 'yoy' ? 'yoy' : 'prev'; + const compare = filters.compare ?? 'prev'; const { startDate, endDate } = getCompareDate(compare, filters.startDate, filters.endDate); diff --git a/src/lib/schema.ts b/src/lib/schema.ts index 38f7339a..aafd8e43 100644 --- a/src/lib/schema.ts +++ b/src/lib/schema.ts @@ -20,7 +20,7 @@ export const dateRangeParams = { endDate: z.coerce.date().optional(), timezone: timezoneParam.optional(), unit: unitParam.optional(), - compare: z.string().optional(), + compare: z.enum(['prev', 'yoy']).optional(), }; export const filterParams = {