Skip to content

cloudflare/durable-objects-rollup-esm

👷 Durable Objects Counter template

Note: You must use wrangler 2.0.0 or newer to use this template.

Please read the Durable Object documentation before using this template.

A template for kick starting a Cloudflare Workers project using:

  • Durable Objects
  • Modules (ES Modules to be specific)
  • Rollup
  • Wrangler

Worker code is in src/. The Durable Object Counter class is in src/counter.mjs, and the eyeball script is in index.mjs.

Rollup is configured to output a bundled ES Module to dist/index.mjs.

Once you have published the worker, you can interact with it as follows:

bash-3.2$ curl worker.your-account-name.workers.dev/
Select a Durable Object to contact by using the `name` URL query string parameter. e.g. ?name=A
bash-3.2$ curl worker.your-account-name.workers.dev/?name=A
Durable Object 'A' 0 is even
bash-3.2$ curl worker.your-account-name.workers.dev/increment?name=A
Durable Object 'A' 1 is odd
bash-3.2$ curl worker.your-account-name.workers.dev/increment?name=A
Durable Object 'A' 2 is even
bash-3.2$ curl worker.your-account-name.workers.dev/decrement?name=A
Durable Object 'A' 1 is odd

About

Template for durable objects, rollup, es modules

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE_APACHE
MIT
LICENSE_MIT

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published