@gusto/create-baerly-storage 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/THIRD-PARTY-LICENSES.txt +204 -0
- package/dist/index.js +1537 -145
- package/dist/index.js.map +1 -1
- package/dist/templates/addons/docker/Dockerfile +13 -11
- package/dist/templates/minimal-cloudflare/AGENTS.md +77 -399
- package/dist/templates/minimal-cloudflare/README.md +33 -97
- package/dist/templates/minimal-cloudflare/package.json +12 -9
- package/dist/templates/minimal-cloudflare/pnpm-workspace.yaml +13 -7
- package/dist/templates/minimal-cloudflare/tsconfig.app.json +2 -3
- package/dist/templates/minimal-cloudflare/tsconfig.worker.json +2 -3
- package/dist/templates/minimal-cloudflare/vitest.config.ts +1 -1
- package/dist/templates/minimal-cloudflare/wrangler.jsonc +4 -2
- package/dist/templates/minimal-node/AGENTS.md +80 -380
- package/dist/templates/minimal-node/README.md +37 -135
- package/dist/templates/minimal-node/package.json +11 -9
- package/dist/templates/minimal-node/pnpm-workspace.yaml +14 -9
- package/dist/templates/minimal-node/tsconfig.app.json +2 -3
- package/dist/templates/minimal-node/tsconfig.server.json +2 -3
- package/dist/templates/react-cloudflare/AGENTS.md +101 -444
- package/dist/templates/react-cloudflare/README.md +14 -54
- package/dist/templates/react-cloudflare/package.json +18 -15
- package/dist/templates/react-cloudflare/pnpm-workspace.yaml +13 -7
- package/dist/templates/react-cloudflare/tsconfig.app.json +2 -3
- package/dist/templates/react-cloudflare/tsconfig.worker.json +2 -3
- package/dist/templates/react-cloudflare/vitest.config.ts +1 -1
- package/dist/templates/react-cloudflare/wrangler.jsonc +4 -2
- package/dist/templates/react-node/AGENTS.md +108 -474
- package/dist/templates/react-node/README.md +35 -125
- package/dist/templates/react-node/package.json +16 -14
- package/dist/templates/react-node/pnpm-workspace.yaml +14 -9
- package/dist/templates/react-node/tsconfig.app.json +2 -3
- package/dist/templates/react-node/tsconfig.server.json +2 -3
- package/package.json +7 -7
- package/dist/templates/minimal-cloudflare/uint8array-base64.d.ts +0 -16
- package/dist/templates/minimal-node/uint8array-base64.d.ts +0 -16
- package/dist/templates/react-cloudflare/uint8array-base64.d.ts +0 -16
- package/dist/templates/react-node/uint8array-base64.d.ts +0 -16
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
# react-cloudflare
|
|
2
2
|
|
|
3
|
-
A baerly-storage app scaffolded with `@gusto/create-baerly-storage` for
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
`@gusto/baerly-storage/cloudflare`. Ships `auth: "none"` so the day-1
|
|
7
|
-
happy path works with zero env vars, plus a one-collection `notes`
|
|
8
|
-
schema you extend; flip to Cloudflare Access or a shared secret before
|
|
9
|
-
deploy — see "Production auth" below.
|
|
10
|
-
|
|
11
|
-
**The R2 bucket is the durable state.** The Worker is trusted app code
|
|
12
|
-
with an R2 binding; it applies the baerly-storage protocol, but it is
|
|
13
|
-
not a database server. No daemon, lock table, scheduler, or idle
|
|
14
|
-
database bill; maintenance is automatic and write-triggered.
|
|
3
|
+
A baerly-storage app scaffolded with `@gusto/create-baerly-storage` for the **Cloudflare Workers** target, with a React + Vite SPA. Single-bucket R2-backed deployment via `@gusto/baerly-storage/cloudflare`. Ships `auth: "none"` so the day-1 happy path works with zero env vars, plus a one-collection `notes` schema you extend; flip to Cloudflare Access or a shared secret before deploy — see "Production auth" below.
|
|
4
|
+
|
|
5
|
+
**The R2 bucket is the durable state.** The Worker is trusted app code with an R2 binding; it applies the baerly-storage protocol, but it is not a database server. No daemon, lock table, scheduler, or idle database bill; maintenance is automatic and write-triggered.
|
|
15
6
|
|
|
16
7
|
## What you got
|
|
17
8
|
|
|
18
|
-
```
|
|
9
|
+
```text
|
|
19
10
|
react-cloudflare/
|
|
20
11
|
├── package.json # one package, all deps
|
|
21
12
|
├── tsconfig.json # project-references stub
|
|
@@ -45,18 +36,11 @@ pnpm install
|
|
|
45
36
|
pnpm dev
|
|
46
37
|
```
|
|
47
38
|
|
|
48
|
-
`pnpm dev` runs Vite. `@cloudflare/vite-plugin` runs the Worker
|
|
49
|
-
inside `workerd` next to the SPA dev server, so the SPA and `/v1/*`
|
|
50
|
-
share an origin (`http://localhost:5173`). First run downloads the
|
|
51
|
-
`workerd` binary.
|
|
39
|
+
`pnpm dev` runs Vite. `@cloudflare/vite-plugin` runs the Worker inside `workerd` next to the SPA dev server, so the SPA and `/v1/*` share an origin (`http://localhost:5173`). First run downloads the `workerd` binary.
|
|
52
40
|
|
|
53
|
-
Open <http://localhost:5173>. Type a note, hit "Add note." Open a
|
|
54
|
-
second tab — inserts, edits, and deletes in one tab appear in the
|
|
55
|
-
other over the `/v1/since?collection=notes&cursor=...` long-poll.
|
|
41
|
+
Open <http://localhost:5173>. Type a note, hit "Add note." Open a second tab — inserts, edits, and deletes in one tab appear in the other over the `/v1/since?collection=notes&cursor=...` long-poll.
|
|
56
42
|
|
|
57
|
-
`pnpm build` runs `tsc -b && vite build`; the SPA lands in
|
|
58
|
-
`dist/client/` for the `assets:` binding in `wrangler.jsonc` to
|
|
59
|
-
serve on deploy.
|
|
43
|
+
`pnpm build` runs `tsc -b && vite build`; the SPA lands in `dist/client/` for the `assets:` binding in `wrangler.jsonc` to serve on deploy.
|
|
60
44
|
|
|
61
45
|
## Deploy
|
|
62
46
|
|
|
@@ -65,15 +49,11 @@ baerly deploy # reads baerly.config.ts:target, runs wran
|
|
|
65
49
|
baerly doctor --target=cloudflare # verify bindings, secrets, optional triggers
|
|
66
50
|
```
|
|
67
51
|
|
|
68
|
-
`baerly doctor --target=cloudflare` warns on `auth: "none"` for
|
|
69
|
-
deploy targets — see "Production auth" below to flip the posture
|
|
70
|
-
before shipping.
|
|
52
|
+
`baerly doctor --target=cloudflare` warns on `auth: "none"` for deploy targets — see "Production auth" below to flip the posture before shipping.
|
|
71
53
|
|
|
72
54
|
## Extend the schema
|
|
73
55
|
|
|
74
|
-
Edit `baerly.config.ts`. The `Note` row type is inferred from
|
|
75
|
-
`NoteSchema` in the same file — adding a field to the schema
|
|
76
|
-
propagates to the UI through `import type { Note }`.
|
|
56
|
+
Edit `baerly.config.ts`. The `Note` row type is inferred from `NoteSchema` in the same file — adding a field to the schema propagates to the UI through `import type { Note }`.
|
|
77
57
|
|
|
78
58
|
```typescript
|
|
79
59
|
export const NoteSchema = z.object({
|
|
@@ -86,34 +66,14 @@ export const NoteSchema = z.object({
|
|
|
86
66
|
|
|
87
67
|
## Production auth
|
|
88
68
|
|
|
89
|
-
The scaffold ships `auth: "none"` so the day-1 happy path works
|
|
90
|
-
|
|
91
|
-
the `
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
- **Pattern A — CF Access (recommended).** Same artifact in dev and
|
|
95
|
-
prod; the factory `verifier:` override engages when
|
|
96
|
-
`CF_ACCESS_TEAM_DOMAIN` + `CF_ACCESS_AUDIENCE_TAG` are present in
|
|
97
|
-
`wrangler.jsonc:vars`. The `cloudflareAccess()` preset
|
|
98
|
-
(re-exported from `@gusto/baerly-storage/auth`) reads the JWT off
|
|
99
|
-
`Cf-Access-Jwt-Assertion`, validates it against your team's JWKS,
|
|
100
|
-
and pins `tenantPrefix` to `config.tenant` unless you pass an
|
|
101
|
-
explicit tenant claim.
|
|
102
|
-
- **Pattern B — `auth: "shared-secret"`.** Single-tenant
|
|
103
|
-
server-to-server callers. Flip `auth` in `baerly.config.ts`, set
|
|
104
|
-
`SHARED_SECRET` via `wrangler secret put`, and re-enable
|
|
105
|
-
`baerlyDevAuth` in `vite.config.ts` for browser bearer injection
|
|
106
|
-
(the SPA never owns the secret — Vite injects it server-side).
|
|
69
|
+
The scaffold ships `auth: "none"` so the day-1 happy path works with zero env vars; every request resolves to `config.tenant` and the `NoteSchema` still validates writes server-side. Before deploy, follow `AGENTS.md` → "Going to production":
|
|
70
|
+
|
|
71
|
+
- **Pattern A — CF Access (recommended).** Same artifact in dev and prod; the factory `verifier:` override engages when `CF_ACCESS_TEAM_DOMAIN` + `CF_ACCESS_AUDIENCE_TAG` are present in `wrangler.jsonc:vars`. The `cloudflareAccess()` preset (re-exported from `@gusto/baerly-storage/auth`) reads the JWT off `Cf-Access-Jwt-Assertion`, validates it against your team's JWKS, and pins `tenantPrefix` to `config.tenant` unless you pass an explicit tenant claim.
|
|
72
|
+
- **Pattern B — `auth: "shared-secret"`.** Single-tenant server-to-server callers. Flip `auth` in `baerly.config.ts`, set `SHARED_SECRET` via `wrangler secret put`, and re-enable `baerlyDevAuth` in `vite.config.ts` for browser bearer injection (the SPA never owns the secret — Vite injects it server-side).
|
|
107
73
|
|
|
108
74
|
## When to graduate
|
|
109
75
|
|
|
110
|
-
baerly-storage is sized for the small-to-medium operating point. Past
|
|
111
|
-
~30 writes/min/collection (throughput estimate), the R2 free-tier
|
|
112
|
-
storage cost line (>10 GB/tenant), or the soft fan-out guideline
|
|
113
|
-
(~100 collections/tenant — linear cost, nothing enforces it),
|
|
114
|
-
graduate to D1 or Postgres via `baerly export --target=postgres`.
|
|
115
|
-
Your data was already in your bucket; the export is a mechanical
|
|
116
|
-
translator, not a vendor migration.
|
|
76
|
+
baerly-storage is sized for the small-to-medium operating point. Past the per-collection write line (throughput estimate), the R2 free-tier storage cost line, or the soft collections-per-tenant guideline (linear cost, nothing enforces it) — figures in docs/spec/scale-ceilings.md § "The published envelope" in the baerly-storage repo — graduate to D1 or Postgres via `baerly export --target=postgres`. Your data was already in your bucket; the export is a mechanical translator, not a vendor migration.
|
|
117
77
|
|
|
118
78
|
## Pointers
|
|
119
79
|
|
|
@@ -13,22 +13,25 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@gusto/baerly-storage": "workspace:*",
|
|
16
|
-
"react": "^19.
|
|
17
|
-
"react-dom": "^19.
|
|
18
|
-
"zod": "^4.
|
|
16
|
+
"react": "^19.3.1",
|
|
17
|
+
"react-dom": "^19.3.1",
|
|
18
|
+
"zod": "^4.6.7"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@cloudflare/vite-plugin": "^1.
|
|
22
|
-
"@cloudflare/workers-types": "^
|
|
23
|
-
"@types/node": "^26.
|
|
24
|
-
"@types/react": "^19.
|
|
25
|
-
"@types/react-dom": "^19.
|
|
26
|
-
"@vitejs/plugin-react": "^6.0
|
|
27
|
-
"happy-dom": "^
|
|
28
|
-
"typescript": "^
|
|
29
|
-
"vite": "^8.
|
|
30
|
-
"vitest": "^
|
|
31
|
-
"wrangler": "^4.
|
|
21
|
+
"@cloudflare/vite-plugin": "^1.69.1",
|
|
22
|
+
"@cloudflare/workers-types": "^5.20261116.1",
|
|
23
|
+
"@types/node": "^26.6.6",
|
|
24
|
+
"@types/react": "^19.3.0",
|
|
25
|
+
"@types/react-dom": "^19.3.0",
|
|
26
|
+
"@vitejs/plugin-react": "^6.3.0",
|
|
27
|
+
"happy-dom": "^21.0.4",
|
|
28
|
+
"typescript": "^7.0.2",
|
|
29
|
+
"vite": "^8.3.8",
|
|
30
|
+
"vitest": "^5.1.0",
|
|
31
|
+
"wrangler": "^4.163.0"
|
|
32
32
|
},
|
|
33
|
-
"
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=26"
|
|
35
|
+
},
|
|
36
|
+
"packageManager": "pnpm@12.22.0"
|
|
34
37
|
}
|
|
@@ -3,13 +3,19 @@
|
|
|
3
3
|
# map, `pnpm install` exits with `ERR_PNPM_IGNORED_BUILDS` for the
|
|
4
4
|
# Cloudflare-stack deps below.
|
|
5
5
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
# platform/runtime combo). Set to `false` to suppress cleanly —
|
|
10
|
-
# sharp still loads from its prebuilt binary at require time, and
|
|
11
|
-
# nothing in a scaffolded baerly app exercises its code path.
|
|
6
|
+
# `esbuild` and `workerd` ship working install scripts we want to run.
|
|
7
|
+
# Any other package that gains an install script fails the install
|
|
8
|
+
# until it is listed here.
|
|
12
9
|
allowBuilds:
|
|
13
10
|
esbuild: true
|
|
14
11
|
workerd: true
|
|
15
|
-
|
|
12
|
+
|
|
13
|
+
# Supply-chain guardrails, strict by default — loosen one deliberately:
|
|
14
|
+
# - minimumReleaseAge: don't resolve a version until it has been on
|
|
15
|
+
# the registry a day, closing the publish-then-yank window.
|
|
16
|
+
# - trustPolicy: fail if a package's publishing trust (provenance,
|
|
17
|
+
# trusted publisher) drops below what earlier versions had.
|
|
18
|
+
# - blockExoticSubdeps: only direct deps may come from git or tarballs.
|
|
19
|
+
minimumReleaseAge: 1440
|
|
20
|
+
trustPolicy: no-downgrade
|
|
21
|
+
blockExoticSubdeps: true
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2024",
|
|
4
|
-
"lib": ["ES2024", "
|
|
4
|
+
"lib": ["ES2024", "ESNext.TypedArrays", "ESNext.Collection", "DOM"],
|
|
5
5
|
"module": "ESNext",
|
|
6
6
|
"moduleResolution": "bundler",
|
|
7
7
|
"allowImportingTsExtensions": true,
|
|
@@ -19,11 +19,10 @@
|
|
|
19
19
|
"isolatedModules": true,
|
|
20
20
|
"erasableSyntaxOnly": true,
|
|
21
21
|
|
|
22
|
-
"esModuleInterop": true,
|
|
23
22
|
"skipLibCheck": true,
|
|
24
23
|
"jsx": "react-jsx",
|
|
25
24
|
"types": ["vite/client"],
|
|
26
25
|
"composite": true
|
|
27
26
|
},
|
|
28
|
-
"include": ["src/web/**/*", "
|
|
27
|
+
"include": ["src/web/**/*", "baerly.config.ts"]
|
|
29
28
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "ES2024",
|
|
4
|
-
"lib": ["ES2024", "
|
|
4
|
+
"lib": ["ES2024", "ESNext.TypedArrays", "ESNext.Collection", "DOM"],
|
|
5
5
|
"module": "ESNext",
|
|
6
6
|
"moduleResolution": "bundler",
|
|
7
7
|
"allowImportingTsExtensions": true,
|
|
@@ -19,10 +19,9 @@
|
|
|
19
19
|
"isolatedModules": true,
|
|
20
20
|
"erasableSyntaxOnly": true,
|
|
21
21
|
|
|
22
|
-
"esModuleInterop": true,
|
|
23
22
|
"skipLibCheck": true,
|
|
24
23
|
"types": ["@cloudflare/workers-types", "node"],
|
|
25
24
|
"composite": true
|
|
26
25
|
},
|
|
27
|
-
"include": ["src/server/**/*", "
|
|
26
|
+
"include": ["src/server/**/*", "baerly.config.ts"]
|
|
28
27
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineConfig } from "vitest/config";
|
|
2
2
|
|
|
3
3
|
// Standalone — `vite.config.ts` loads `@cloudflare/vite-plugin`, which
|
|
4
|
-
// rejects vitest's pool/environment combo. Add `@cloudflare/vitest-
|
|
4
|
+
// rejects vitest's pool/environment combo. Add `@cloudflare/vitest-plugin`
|
|
5
5
|
// here if you want Worker-side integration tests.
|
|
6
6
|
export default defineConfig({
|
|
7
7
|
test: {
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
"$schema": "node_modules/wrangler/config-schema.json",
|
|
6
6
|
"name": "react-cloudflare",
|
|
7
7
|
"main": "./src/server/index.ts",
|
|
8
|
-
"compatibility_date": "2026-
|
|
9
|
-
|
|
8
|
+
"compatibility_date": "2026-10-23",
|
|
9
|
+
// `enable_request_signal` lets `/v1/since` see client disconnects. It is the
|
|
10
|
+
// default from compatibility_date 2026-11-17; drop it when the date moves past that.
|
|
11
|
+
"compatibility_flags": ["nodejs_compat", "enable_request_signal"],
|
|
10
12
|
|
|
11
13
|
"r2_buckets": [
|
|
12
14
|
{
|