Commit 16ad838
committed
Add database, auth, and org infrastructure for the website worker
## db/ package (new workspace package)
Drizzle ORM schema with D1 SQLite targeting Cloudflare Workers:
- **BetterAuth core tables**: user, session, account, verification
- **Org hierarchy**: org, orgMember (many-to-many user<>org with role enum)
- **Device flow**: deviceCode table for CLI/agent login (RFC 8628)
- All timestamps use epochMs custom type for D1 Date compat
- All IDs are ULIDs, all FKs have cascade delete + indexes
- Relations wired with defineRelations v2 (including many-to-many through)
- Dual entrypoints: workerd.ts (drizzle-orm/d1) and node.ts (D1 HTTP API)
- flatten-migrations.ts script for wrangler D1 compatibility
- First migration generated and flattened
## website/ auth + UI
- **src/db.ts**: getDb(), getAuth() with Google social + device flow + bearer
plugins, cookie caching, getSession(), requireSession(), requireOrgMember()
- **server.tsx**: BetterAuth middleware on /api/auth/*, login page (/login),
Google OAuth redirect (/login/google), device flow page (/device) with
approve/deny server actions
- **Tailwind v4 + shadcn tokens**: globals.css with light/dark mode via
@variant dark, cn() utility, Button component with form pending states,
DeviceActionButtons client component
- **wrangler.jsonc**: D1 bindings (holocron-db + holocron-preview-db),
BETTER_AUTH_SECRET/GOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET secrets,
BETTER_AUTH_URL vars per environment
- **package.json**: Added better-auth, drizzle-orm@beta, tailwindcss,
shadcn deps. Migration scripts for local/preview/prod D1.
- **vite.config.ts**: Added react + tailwind plugins
- **tsconfig.json**: Added JSX, DOM lib, worker-configuration.d.ts
## Root
- tsconfig.base.json: shared strict ESNext config for all packages
- .gitignore: added .dev.vars, .env.*, worker-configuration.d.ts
## Sigillo
Created holocron org + website project with dev/preview/prod environments.
Placeholder secrets added: BETTER_AUTH_SECRET, GOOGLE_CLIENT_ID,
GOOGLE_CLIENT_SECRET, CF_API_TOKEN, AIG_GATEWAY_TOKEN.
## D1 databases created
- holocron-db (prod): 1b6a43e2-2e03-408c-9199-291faa305fa4
- holocron-preview-db (preview): 8c7b5000-0d42-4c55-9a0a-ecad450f1e3d
Session: ses_243dcc460ffeCk1FXcCKm4HFhj1 parent 156da43 commit 16ad838
25 files changed
Lines changed: 5350 additions & 182 deletions
File tree
- db
- drizzle
- 20260423211231_clumsy_electro
- scripts
- src
- website
- src
- components
- ui
- lib
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
0 commit comments