Skip to content

docs(examples): run the Cloudflare example on D1 and a Durable Object - #324

Merged
anurag629 merged 1 commit into
devfrom
docs/cloudflare-d1-example
Oct 25, 2026
Merged

anurag629 merged 1 commit into
devfrom
docs/cloudflare-d1-example

Conversation

@anurag629

Copy link
Copy Markdown
Member

F-03 task 14, the example half. The full Cloudflare Worker example now uses @chatcops/store-cloudflare:

  • Conversations live in D1 and counters in the ChatCopsCounter Durable Object (exported from the Worker).
  • The Worker passes ctx to the handler, so webhooks and analytics writes finish after the reply.
  • It sets retention, a real allowedOrigins and a globalPerDay budget.
  • wrangler.toml gets the D1 binding, the DO binding with its SQLite migration, and nodejs_compat. The page also has wrangler d1 create, a note on running without the DO (counters in D1), and a link to the scheduled purge recipe.
  • It replaces the "planned" note that pointed at Create @chatcops/store-cloudflare (D1, KV and a Durable Object counter) #249.

The small example in packages/server/src/examples/cloudflare-worker.ts swaps the deprecated cors for allowedOrigins. An empty changeset covers that, since it is only an example.

The store package is not on npm yet: it is at 0.1.0 and still private until its first publish. This page only goes live with the next release, which should come after that publish.

Checks: the website builds, and so does the server.

@anurag629
anurag629 merged commit 8acc6cf into dev Oct 25, 2026
5 checks passed
@anurag629
anurag629 deleted the docs/cloudflare-d1-example branch October 25, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant