From c95a4a26c92d25207035cd93968d4d4d54264014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20M=C3=B3ricz?= Date: Fri, 15 Nov 2024 18:58:03 +0100 Subject: [PATCH] fix(v1/batch/scrape): raise default timeout --- apps/api/src/controllers/v1/types.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/apps/api/src/controllers/v1/types.ts b/apps/api/src/controllers/v1/types.ts index e14087e1..3b4c8399 100644 --- a/apps/api/src/controllers/v1/types.ts +++ b/apps/api/src/controllers/v1/types.ts @@ -186,9 +186,10 @@ export const webhookSchema = z.preprocess(x => { headers: z.record(z.string(), z.string()).default({}), }).strict(strictMessage)) -export const batchScrapeRequestSchema = scrapeOptions.extend({ +export const batchScrapeRequestSchema = scrapeOptions.omit({ timeout: true }).extend({ urls: url.array(), origin: z.string().optional().default("api"), + timeout: z.number().int().positive().finite().safe().default(60000), webhook: webhookSchema.optional(), }).strict(strictMessage).refine( (obj) => { @@ -199,12 +200,7 @@ export const batchScrapeRequestSchema = scrapeOptions.extend({ { message: "When 'extract' format is specified, 'extract' options must be provided, and vice versa", } -).transform((obj) => { - if ((obj.formats?.includes("extract") || obj.extract) && !obj.timeout) { - return { ...obj, timeout: 60000 }; - } - return obj; -}); +); export type BatchScrapeRequest = z.infer;