Attested hosting for Cloudflare Workers.
codius-astro
- Astro site for managing workersdispatch-worker
- Workers for Platforms1 dynamic dispatch workerbilling-durable-object
- Durable Object for worker billing
pnpm install
sequenceDiagram
actor User
box Cloudflare
participant Astro
participant Action as Astro Action (Worker)
participant D1
participant Workers as Workers for Platforms
end
box GitHub
participant GitHub as GitHub Actions
participant Repo as GitHub app repo
end
User->>+Astro: worker app info formdata
Astro->>+Action: app info
Action->>D1: INSERT app
Action-x+GitHub: trigger workflow
GitHub->>+Repo: git checkout
Repo-->>-GitHub: repo
GitHub->>+Workers: wrangler deploy --namespace
Action-->>-Astro: app
Astro-->>-User: app
sequenceDiagram
actor User
box Cloudflare
participant Dispatch as Dispatch Worker
participant DO as Billing Durable Object
participant Worker
end
User->>+Dispatch: GET <id>.codius-workers.pages.dev
Dispatch->>+DO: billing.incrementWorkerRequests()
alt insufficient balance
DO->>Dispatch: throw new Error(LIMIT_EXCEEDED_MESSAGE)
else
DO->>-Dispatch: OK
Dispatch->>+Worker: userWorker.fetch(request)
deactivate Dispatch
Worker-->>-User: 200 resp
end
sequenceDiagram
actor User
box Cloudflare
participant Astro
participant Action as Astro Action (Worker)
participant DO as Billing Durable Object
end
box Stripe
participant StripeAPI as Stripe API
participant Checkout
end
activate User
User->>+Astro: clicks "Top Up" button
Astro->>+Action: actions.checkoutSession.create
Action->>+StripeAPI: stripe.checkout.sessions.create
StripeAPI-->>-Action: session
Action-->>-Astro: session.url
Astro->>+Checkout: Navigate to session URL
deactivate Astro
Checkout-xUser: payment page
User->>Checkout: payment info
Checkout->>+Astro: Navigate to success url
deactivate Checkout
Astro->>+DO: billing.addWorkerFunds
Astro-->>-User: success page
deactivate User