Spaces:
Sleeping
Sleeping
Download apps/api/src/services/webhook/schema.ts from s-eto-hub/firecrawl-api: direct link, hf CLI and curl.
- Browser
- Download file 955 Bytes
-
https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/services/webhook/schema.ts
- Command line
-
hf download hf://spaces/s-eto-hub/firecrawl-api/apps/api/src/services/webhook/schema.ts
-
curl -L -o schema.ts https://huggingface.co/spaces/s-eto-hub/firecrawl-api/resolve/main/apps/api/src/services/webhook/schema.ts
955 Bytes
| import { z } from "zod"; | |
| const BLACKLISTED_WEBHOOK_HEADERS = ["x-firecrawl-signature"]; | |
| export function createWebhookSchema<T extends [string, ...string[]]>( | |
| events: T, | |
| ) { | |
| const blacklistedLower = BLACKLISTED_WEBHOOK_HEADERS.map(h => | |
| h.toLowerCase(), | |
| ); | |
| return z.preprocess( | |
| x => (typeof x === "string" ? { url: x } : x), | |
| z | |
| .strictObject({ | |
| url: z.url(), | |
| headers: z.record(z.string(), z.string()).prefault({}), | |
| metadata: z.record(z.string(), z.string()).prefault({}), | |
| events: z.array(z.enum(events)).prefault([...events]), | |
| }) | |
| .refine( | |
| obj => | |
| !Object.keys(obj.headers).some(key => | |
| blacklistedLower.includes(key.toLowerCase()), | |
| ), | |
| `The following headers are not allowed: ${BLACKLISTED_WEBHOOK_HEADERS.join(", ")}`, | |
| ), | |
| ); | |
| } | |
| export const webhookSchema = createWebhookSchema([ | |
| "completed", | |
| "failed", | |
| "page", | |
| "started", | |
| ]); | |