Skip to content

codius/codius-workers

Repository files navigation

Codius Workers

Attested hosting for Cloudflare Workers.

🧩 Packages

🔧 Setup

Install dependencies

pnpm install

Flows

Worker deployment

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
Loading

Worker request

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
Loading

Worker billing

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
Loading

Footnotes

  1. Workers for Platforms requires a Paid plan.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published