Created
November 7, 2024 09:56
-
-
Save arbaaz/f487a14db084636a939c69eba261a675 to your computer and use it in GitHub Desktop.
Cloudflare Workflow template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
WorkflowEntrypoint, | |
WorkflowEvent, | |
WorkflowStep, | |
} from "cloudflare:workers"; | |
import { NonRetryableError } from "cloudflare:workflows"; | |
export type ScrapeParams = { | |
url: string; | |
}; | |
export class ScrapeWorkflow extends WorkflowEntrypoint< | |
CloudflareBindings, | |
ScrapeParams | |
> { | |
async run(event: WorkflowEvent<ScrapeParams>, step: WorkflowStep) { | |
const { url } = event.payload; | |
if (url === "https://example.com") { | |
throw new NonRetryableError(`Website ${url} failed moderation`); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment