Skip to main content
Cloudflare Workers run on the V8 edge runtime — no Node.js, no npm packages needed. All three examples use the native fetch API and store the API key as a Wrangler secret so it never touches your codebase.

Prerequisites

Create a Worker

Choose “Hello World” Worker when prompted. Select TypeScript.

Set your API key

Store the key as a secret — never hardcode it:
.dev.vars is the Workers equivalent of .env. It is gitignored by default. Do not commit it.
Declare the binding in wrangler.toml so TypeScript knows it exists:
wrangler.toml
Add the type to your Worker’s Env interface:
src/index.ts

Shared helper

A small typed helper keeps each handler clean:
src/geekflare.ts

Web Scraping

src/index.ts
Test locally:

Route requests to different Geekflare endpoints based on the URL path:
src/index.ts
Test locally:

Screenshot

src/index.ts

Complete multi-route Worker

A single Worker handling all three endpoints:
src/index.ts

Deploy


Error handling

See Rate Limit Exceeded and Credit Exhausted for strategies to handle these gracefully.
The geekflarePost helper above throws on non-2xx responses. Wrap every handler in try/catch and map error codes to appropriate HTTP responses:

Next steps