Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,34 @@ pnpm --filter @app/web dev # http://localhost:3000 — the local
pnpm --filter @app/web preview # wrangler dev over the built Worker, same local bindings
```

## Deploying

The Orun pipeline (`.github/workflows/ci.yml`) plans nothing while
`intent.yaml` names the placeholder workspace `ws_CHANGE_ME`. Link the
repository to an Orun Cloud workspace (`orun cloud link`), set
`execution.state.workspace` to it, connect Cloudflare in the workspace, and
every merge to `main` then applies the D1 database, the KV namespace and the
R2 bucket, migrates the database and deploys `better-auth-starter-web-stage`,
then `-prod`, each smoke-tested on `/api/health`. A pull request verifies the
same lanes and deploys nothing. A manual run of `ci.yml` (Run workflow on
`main`, or Orunbase's Deploy button) redeploys the components it names.

The deploy needs nothing typed: the auth secret is generated in each
environment's database by the migrations, and the sign-in page works with no
provider. R2 must be enabled on the Cloudflare account once (the dashboard
asks for a payment method even on the free tier); until it is, the R2 root's
apply fails.

## Custom domain

The Worker answers on `workers.dev` from its first deploy. To serve it on a
domain of your own, attach the domain to the Worker in Cloudflare (Workers &
Pages → the Worker → Settings → Domains & Routes) and replace
`better-auth-starter.example.com` in `intent.yaml`'s `BASE_DOMAIN`. better-auth
takes the origin each request arrives on, so sign-in works on the new domain
without changing a line; set `BETTER_AUTH_URL` only to pin one origin (an
OAuth app's callback URL must match it).

## Sign-in providers

Anonymous and email-and-password sign-in work with nothing configured.
Expand Down
2 changes: 1 addition & 1 deletion specs/epics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ folder is the adoption; the merge creates the epic in the workspace.

| Epic | Cluster | Status | What it is |
|------|---------|--------|------------|
| [`better-auth-starter/`](./better-auth-starter/) | **BA** | In progress (BA2) | zpg6's better-auth-cloudflare OpenNext example — anonymous, email and OAuth sign-in through better-auth, sessions in KV, users in D1, file uploads in R2 — on Cloudflare Workers, and an Orun baseline that instantiates it in one landing |
| [`better-auth-starter/`](./better-auth-starter/) | **BA** | In progress (BA3) | zpg6's better-auth-cloudflare OpenNext example — anonymous, email and OAuth sign-in through better-auth, sessions in KV, users in D1, file uploads in R2 — on Cloudflare Workers, and an Orun baseline that instantiates it in one landing |

As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`.
15 changes: 13 additions & 2 deletions specs/epics/better-auth-starter/IMPLEMENTATION-STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@
|---|---|---|
| BA0 — the spec | ✅ Shipped | [#1](https://github.com/sourceplane/better-auth-starter/pull/1) |
| BA1 — the auth app on Workers | ✅ Shipped | [#2](https://github.com/sourceplane/better-auth-starter/pull/2) |
| BA2 — D1, KV and R2 from Terraform | In progress | |
| BA3 — ready to instantiate | Not started | |
| BA2 — D1, KV and R2 from Terraform | ✅ Shipped | [#3](https://github.com/sourceplane/better-auth-starter/pull/3) |
| BA3 — ready to instantiate | In progress | |
| BA4 — a baseline | Not started | |

## What is proven, and how

| Claim | Proven by |
|---|---|
| The app builds into one Worker within Workers Free's 3 MiB (1,911 KiB gzipped) | `pnpm build` + `wrangler deploy --dry-run` |
| Email sign-up, the session, the redirect to the dashboard, the dashboard, a file through R2 and back, anonymous sign-in | `wrangler dev` over the local D1 after `db:migrate:local` (BA1) |
| The migrations apply into real SQLite through the runner, twice | `tests/db` |
| The providers, the generated secret, the health route, the redirects | `tests/web` |
| The roots are valid Terraform; the plan orders roots → migrations → Worker | `terraform validate`; `orun plan` (BA2) |
| The applies, the migrations and the deploy on a real account | only a live bootstrap (risk BA-F) |

## Departures from the upstream example

1. **Next.js 16.3.8** (the example: 15.5): the reference starters' toolchain. `middleware.ts` is `proxy.ts` (Next 16's name), its logic unchanged except that it no longer logs each signed-in visitor's city and country.
Expand Down
2 changes: 1 addition & 1 deletion specs/epics/better-auth-starter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The port keeps the sign-in page, the dashboard (user, geolocation and file-uploa

| Field | Value |
|-------|-------|
| Status | In progress — BA0 (#1) and BA1 (#2) shipped, BA2 |
| Status | In progress — BA0 (#1), BA1 (#2) and BA2 (#3) shipped, BA3 |
| Cluster | **BA** (BA0–BA4) |
| Owner(s) | `apps/web` · `tests/web` · `infra/terraform/cloudflare-{d1,kv,r2}` · `packages/db` + `infra/db-migrate` · `tests/db` |
| Builds on | `turso-starter`: its scaffolding, its `cloudflare-d1` root and its migrations runner; `kv-redis-starter`'s `cloudflare-kv` root; `blob-starter`'s `cloudflare-r2` root; `saas-starter`'s generated app secret |
Expand Down
Loading