Skip to content

jahands/alchemy-workers-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alchemy-workers-demo

Demo showing how to use Alchemy with multiple Workers that RPC to each other

Usage

Prerequisites

Before running the commands below, add a .env file in the root with these set:

CLOUDFLARE_ACCOUNT_ID=xyz
ALCHEMY_STATE_TOKEN=xyz

The alchemy state token should be a secret - you can generate a new secret via:

openssl rand -base64 32

Commands

# install dependencies
pnpm install

# switch to alchemy package used to deploy all our apps (workers)
cd infra/alchemy

# authenticate alchemy to Cloudflare
bun alchemy login

# local dev
bun alchemy dev

# deploy
bun alchemy deploy --stage=prod

How it works

Each app declares it's resources in an alchemy.resources.ts file using custom Alchemy resources. Currently we have:

We connect everything together in the infra/alchemy package via infra/alchemy/alchemy.run.ts

Shared resources such as R2 buckets are passed in dependency-injection style when we create the custom resource:

const r2Bucket = await R2Bucket('bucket')
const acmeApi = await AcmeApi('api', {
  r2Bucket, // dependency injection
})

State

We're currently storing state remotely using the Cloudflare State Store which creates a Worker within your account and stores state within a Durable Object.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors