This is a collection of examples of communicating between multiple Cloudflare Workers using the remote-procedure call (RPC) system that is built into the Workers runtime.
Specifically, these examples highight patterns for how to expose multiple named entrypoints from a single Cloudflare Worker, and bind directly to them using Service bindings.
Learn more about the RPC system in Cloudflare Workers by reading the blog post.
-
This is a comprehensive "to do" application example. It is composed of three different services, a D1 database, two web applications (one protected by Cloudflare Access), and two different Worker Entrypoints for different user role permission levels.
-
This is a Discord bot, written as a Worker Entrypoint. It sketches a possible future where application integrations could be written as Worker Entrypoints, without needing to worry about boilerplate like routing or authentication (and instead, just with simple JavaScript hook-like functionality).
- Clone this repository:
git clone https://github.com/cloudflare/js-rpc-and-entrypoints-demo.git && cd js-rpc-and-entrypoints-demo
npm install
in the root of this monorepo.cd
into one of the applications, and open itsREADME.md
to learn more.