Converted UTM report to a view.
This commit is contained in:
1 parent
06f76dda13
commit
d0d11225f4
24 files changed
+1815
-1568
No files matched your search
+3
-13
@@ -1,4 +1,4 @@
|
||||
import { z, ZodSchema } from 'zod';
|
||||
import { z } from 'zod/v4';
|
||||
import { FILTER_COLUMNS } from '@/lib/constants';
|
||||
import { badRequest, unauthorized } from '@/lib/response';
|
||||
import { getAllowedUnits, getMinimumUnit } from '@/lib/date';
|
||||
@@ -7,7 +7,7 @@ import { getWebsiteDateRange } from '@/queries';
|
||||
|
||||
export async function parseRequest(
|
||||
request: Request,
|
||||
schema?: ZodSchema,
|
||||
schema?: any,
|
||||
options?: { skipAuth: boolean },
|
||||
): Promise<any> {
|
||||
const url = new URL(request.url);
|
||||
@@ -21,7 +21,7 @@ export async function parseRequest(
|
||||
const result = schema.safeParse(isGet ? query : body);
|
||||
|
||||
if (!result.success) {
|
||||
error = () => badRequest(getErrorMessages(result.error));
|
||||
error = () => badRequest(z.treeifyError(result.error));
|
||||
} else if (isGet) {
|
||||
query = result.data;
|
||||
} else {
|
||||
@@ -87,13 +87,3 @@ export function getRequestFilters(query: Record<string, any>) {
|
||||
return obj;
|
||||
}, {});
|
||||
}
|
||||
|
||||
export function getErrorMessages(error: z.ZodError) {
|
||||
return Object.entries(error.format())
|
||||
.flatMap(([key, value]) => {
|
||||
if (key === '_errors') {
|
||||
return value;
|
||||
}
|
||||
})
|
||||
.filter(Boolean);
|
||||
}
|
||||
Reference in new issue
Block a user