@gusto/create-baerly-storage 0.1.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.
Files changed (88) hide show
  1. package/dist/index.js +2737 -0
  2. package/dist/index.js.map +1 -0
  3. package/dist/templates/addons/docker/.dockerignore +13 -0
  4. package/dist/templates/addons/docker/Dockerfile +65 -0
  5. package/dist/templates/addons/docker/healthcheck.js +15 -0
  6. package/dist/templates/minimal-cloudflare/.baerly/scaffold.json +10 -0
  7. package/dist/templates/minimal-cloudflare/AGENTS.md +556 -0
  8. package/dist/templates/minimal-cloudflare/README.md +169 -0
  9. package/dist/templates/minimal-cloudflare/_gitignore +6 -0
  10. package/dist/templates/minimal-cloudflare/baerly.config.ts +20 -0
  11. package/dist/templates/minimal-cloudflare/index.html +12 -0
  12. package/dist/templates/minimal-cloudflare/package.json +28 -0
  13. package/dist/templates/minimal-cloudflare/pnpm-workspace.yaml +15 -0
  14. package/dist/templates/minimal-cloudflare/src/notes.test.ts +19 -0
  15. package/dist/templates/minimal-cloudflare/src/server/index.ts +11 -0
  16. package/dist/templates/minimal-cloudflare/src/web/main.ts +27 -0
  17. package/dist/templates/minimal-cloudflare/tsconfig.app.json +28 -0
  18. package/dist/templates/minimal-cloudflare/tsconfig.json +9 -0
  19. package/dist/templates/minimal-cloudflare/tsconfig.worker.json +28 -0
  20. package/dist/templates/minimal-cloudflare/types.ts +23 -0
  21. package/dist/templates/minimal-cloudflare/uint8array-base64.d.ts +16 -0
  22. package/dist/templates/minimal-cloudflare/vite.config.ts +6 -0
  23. package/dist/templates/minimal-cloudflare/vitest.config.ts +11 -0
  24. package/dist/templates/minimal-cloudflare/wrangler.jsonc +27 -0
  25. package/dist/templates/minimal-node/.baerly/scaffold.json +13 -0
  26. package/dist/templates/minimal-node/.env.example +14 -0
  27. package/dist/templates/minimal-node/AGENTS.md +488 -0
  28. package/dist/templates/minimal-node/README.md +180 -0
  29. package/dist/templates/minimal-node/_gitignore +7 -0
  30. package/dist/templates/minimal-node/baerly.config.ts +20 -0
  31. package/dist/templates/minimal-node/index.html +12 -0
  32. package/dist/templates/minimal-node/package.json +26 -0
  33. package/dist/templates/minimal-node/pnpm-workspace.yaml +9 -0
  34. package/dist/templates/minimal-node/src/notes.test.ts +19 -0
  35. package/dist/templates/minimal-node/src/server/index.ts +46 -0
  36. package/dist/templates/minimal-node/src/web/main.ts +27 -0
  37. package/dist/templates/minimal-node/tsconfig.app.json +28 -0
  38. package/dist/templates/minimal-node/tsconfig.json +9 -0
  39. package/dist/templates/minimal-node/tsconfig.server.json +28 -0
  40. package/dist/templates/minimal-node/types.ts +23 -0
  41. package/dist/templates/minimal-node/uint8array-base64.d.ts +16 -0
  42. package/dist/templates/minimal-node/vite.config.ts +15 -0
  43. package/dist/templates/minimal-node/vitest.config.ts +12 -0
  44. package/dist/templates/react-cloudflare/.baerly/scaffold.json +10 -0
  45. package/dist/templates/react-cloudflare/AGENTS.md +715 -0
  46. package/dist/templates/react-cloudflare/README.md +115 -0
  47. package/dist/templates/react-cloudflare/_gitignore +6 -0
  48. package/dist/templates/react-cloudflare/baerly.config.ts +37 -0
  49. package/dist/templates/react-cloudflare/index.html +12 -0
  50. package/dist/templates/react-cloudflare/package.json +34 -0
  51. package/dist/templates/react-cloudflare/pnpm-workspace.yaml +15 -0
  52. package/dist/templates/react-cloudflare/src/notes.test.ts +19 -0
  53. package/dist/templates/react-cloudflare/src/server/index.ts +12 -0
  54. package/dist/templates/react-cloudflare/src/web/App.tsx +38 -0
  55. package/dist/templates/react-cloudflare/src/web/NoteList.tsx +93 -0
  56. package/dist/templates/react-cloudflare/src/web/client.ts +13 -0
  57. package/dist/templates/react-cloudflare/src/web/main.tsx +14 -0
  58. package/dist/templates/react-cloudflare/src/web/styles.css +57 -0
  59. package/dist/templates/react-cloudflare/tsconfig.app.json +29 -0
  60. package/dist/templates/react-cloudflare/tsconfig.json +9 -0
  61. package/dist/templates/react-cloudflare/tsconfig.worker.json +28 -0
  62. package/dist/templates/react-cloudflare/uint8array-base64.d.ts +16 -0
  63. package/dist/templates/react-cloudflare/vite.config.ts +7 -0
  64. package/dist/templates/react-cloudflare/vitest.config.ts +11 -0
  65. package/dist/templates/react-cloudflare/wrangler.jsonc +27 -0
  66. package/dist/templates/react-node/.baerly/scaffold.json +13 -0
  67. package/dist/templates/react-node/.env.example +14 -0
  68. package/dist/templates/react-node/AGENTS.md +662 -0
  69. package/dist/templates/react-node/README.md +187 -0
  70. package/dist/templates/react-node/_gitignore +7 -0
  71. package/dist/templates/react-node/baerly.config.ts +37 -0
  72. package/dist/templates/react-node/index.html +12 -0
  73. package/dist/templates/react-node/package.json +32 -0
  74. package/dist/templates/react-node/pnpm-workspace.yaml +9 -0
  75. package/dist/templates/react-node/src/notes.test.ts +19 -0
  76. package/dist/templates/react-node/src/server/index.ts +48 -0
  77. package/dist/templates/react-node/src/web/App.tsx +38 -0
  78. package/dist/templates/react-node/src/web/NoteList.tsx +93 -0
  79. package/dist/templates/react-node/src/web/client.ts +13 -0
  80. package/dist/templates/react-node/src/web/main.tsx +14 -0
  81. package/dist/templates/react-node/src/web/styles.css +57 -0
  82. package/dist/templates/react-node/tsconfig.app.json +29 -0
  83. package/dist/templates/react-node/tsconfig.json +9 -0
  84. package/dist/templates/react-node/tsconfig.server.json +28 -0
  85. package/dist/templates/react-node/uint8array-base64.d.ts +16 -0
  86. package/dist/templates/react-node/vite.config.ts +17 -0
  87. package/dist/templates/react-node/vitest.config.ts +12 -0
  88. package/package.json +41 -0
@@ -0,0 +1,115 @@
1
+ # react-cloudflare
2
+
3
+ A baerly app scaffolded with `@gusto/create-baerly-storage` for the **Cloudflare
4
+ Workers** target, with a React + Vite SPA. Single-bucket R2-backed
5
+ deployment via `@gusto/baerly-storage/cloudflare`. Ships `auth: "none"`
6
+ so the day-1 happy path works with zero env vars, plus a
7
+ one-collection `notes` schema you extend; flip to Cloudflare Access
8
+ or a shared secret before deploy — see "Production auth" below.
9
+
10
+ ## What you got
11
+
12
+ ```
13
+ react-cloudflare/
14
+ ├── package.json # one package, all deps
15
+ ├── tsconfig.json # project-references stub
16
+ ├── tsconfig.app.json # client TS project (src/web)
17
+ ├── tsconfig.worker.json # Worker TS project (src/server)
18
+ ├── vite.config.ts # Vite + @vitejs/plugin-react + @cloudflare/vite-plugin
19
+ ├── wrangler.jsonc # Worker manifest — R2 binding, assets, vars, cron, observability
20
+ ├── index.html # SPA shell — Vite's entry point
21
+ ├── baerly.config.ts # app, tenant, target, NoteSchema, `Note` type
22
+ ├── AGENTS.md # deeper guide: hooks, schema, auth, deploy
23
+ ├── CLAUDE.md # same content (Claude Code reads this)
24
+ ├── src/
25
+ │ ├── server/
26
+ │ │ └── index.ts # baerlyWorker((env) => ({ verifier }))
27
+ │ └── web/
28
+ │ ├── main.tsx # React entry
29
+ │ ├── App.tsx # Provider + new-note form (useMutation)
30
+ │ ├── client.ts # BaerlyClient bound to this config
31
+ │ └── NoteList.tsx # useQuery + per-row useMutation
32
+ └── README.md
33
+ ```
34
+
35
+ ## Run locally
36
+
37
+ ```sh
38
+ pnpm install
39
+ pnpm dev
40
+ ```
41
+
42
+ `pnpm dev` runs Vite. `@cloudflare/vite-plugin` runs the Worker
43
+ inside `workerd` next to the SPA dev server, so the SPA and `/v1/*`
44
+ share an origin (`http://localhost:5173`). First run downloads the
45
+ `workerd` binary.
46
+
47
+ Open <http://localhost:5173>. Type a note, hit "Add note." Open a
48
+ second tab — inserts, edits, and deletes in one tab appear in the
49
+ other over the `/v1/since` long-poll.
50
+
51
+ `pnpm build` runs `tsc -b && vite build`; the SPA lands in
52
+ `dist/client/` for the `assets:` binding in `wrangler.jsonc` to
53
+ serve on deploy.
54
+
55
+ ## Deploy
56
+
57
+ ```sh
58
+ baerly deploy # reads baerly.config.ts:target, runs wrangler deploy
59
+ baerly doctor --target=cloudflare # verify bindings, secrets, cron
60
+ ```
61
+
62
+ `baerly doctor --target=cloudflare` warns on `auth: "none"` for
63
+ deploy targets — see "Production auth" below to flip the posture
64
+ before shipping.
65
+
66
+ ## Extend the schema
67
+
68
+ Edit `baerly.config.ts`. The `Note` row type is inferred from
69
+ `NoteSchema` in the same file — adding a field to the schema
70
+ propagates to the UI through `import type { Note }`.
71
+
72
+ ```typescript
73
+ export const NoteSchema = z.object({
74
+ _id: z.string(),
75
+ body: z.string().min(1),
76
+ // Add fields here:
77
+ tags: z.array(z.string()).optional(),
78
+ });
79
+ ```
80
+
81
+ ## Production auth
82
+
83
+ The scaffold ships `auth: "none"` so the day-1 happy path works
84
+ with zero env vars; every request resolves to `config.tenant` and
85
+ the `NoteSchema` still validates writes server-side. Before deploy,
86
+ follow `AGENTS.md` → "Going to production":
87
+
88
+ - **Pattern A — CF Access (recommended).** Same artifact in dev and
89
+ prod; the factory `verifier:` override engages when
90
+ `CF_ACCESS_TEAM_DOMAIN` + `CF_ACCESS_AUDIENCE_TAG` are present in
91
+ `wrangler.jsonc:vars`. The `cloudflareAccess()` preset
92
+ (re-exported from `@gusto/baerly-storage/auth`) reads the JWT off
93
+ `Cf-Access-Jwt-Assertion`, validates it against your team's JWKS,
94
+ and derives `tenantPrefix` from the email claim.
95
+ - **Pattern B — `auth: "shared-secret"`.** Single-tenant
96
+ server-to-server callers. Flip `auth` in `baerly.config.ts`, set
97
+ `SHARED_SECRET` via `wrangler secret put`, and re-enable
98
+ `baerlyDevAuth` in `vite.config.ts` for browser bearer injection
99
+ (the SPA never owns the secret — Vite injects it server-side).
100
+
101
+ ## When to graduate
102
+
103
+ baerly is sized for the small-to-medium operating point. Past
104
+ ~30 writes/min/collection, ~10 GB/tenant, or ~100 collections/
105
+ tenant, graduate to D1 or Postgres via `baerly export
106
+ --target=postgres`. Your data was already in your bucket; the
107
+ export is a mechanical translator, not a vendor migration.
108
+
109
+ ## Pointers
110
+
111
+ - `baerly.config.ts` — app config + Zod schema.
112
+ - `src/server/index.ts` — Worker fetch + scheduled handler.
113
+ - `src/web/NoteList.tsx` — `useQuery` reactive read.
114
+ - `wrangler.jsonc` — Cloudflare Worker manifest.
115
+ - `AGENTS.md` / `CLAUDE.md` — agent-facing guide (byte-identical).
@@ -0,0 +1,6 @@
1
+ node_modules/
2
+ dist/
3
+ .wrangler/
4
+ .dev.vars
5
+ .DS_Store
6
+ *.tsbuildinfo
@@ -0,0 +1,37 @@
1
+ import { z } from "zod";
2
+ import { defineConfig } from "@gusto/baerly-storage/config";
3
+
4
+ /**
5
+ * Zod schema for one note. Source of truth for both the runtime
6
+ * `SchemaValidator` consumed by `baerly-storage`'s writer and the
7
+ * compile-time `Note` row type imported by the UI.
8
+ */
9
+ export const NoteSchema = z.object({
10
+ // Auto-stamped by the kernel on insert (UUIDv7) — never provide it from the
11
+ // client. Declared here so `z.infer<typeof NoteSchema>` produces a row type
12
+ // that includes `_id`, which the UI reads via `n._id`. UUIDv7 sorts
13
+ // by server mint time, so the list orders newest-first via `_id` —
14
+ // no separate `created_at` column needed.
15
+ _id: z.string(),
16
+ body: z.string().min(1),
17
+ });
18
+
19
+ /**
20
+ * Compile-time row type derived from {@link NoteSchema}. Single
21
+ * source of truth — adding a field to the schema adds it here.
22
+ *
23
+ * **Replacing the demo?** `src/web/{App,NoteList}.tsx` import
24
+ * `Note` from this file; rename `NoteSchema` first and the
25
+ * inferred type follows.
26
+ */
27
+ export type Note = z.infer<typeof NoteSchema>;
28
+
29
+ export default defineConfig({
30
+ app: "react-cloudflare",
31
+ tenant: "react-demo",
32
+ target: "cloudflare",
33
+ auth: "none",
34
+ collections: {
35
+ notes: { schema: NoteSchema },
36
+ },
37
+ });
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Notes</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/web/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "react-cloudflare",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "deploy": "wrangler deploy",
10
+ "test": "vitest run",
11
+ "typecheck": "tsc -b --noEmit",
12
+ "verify": "pnpm run typecheck && pnpm run test"
13
+ },
14
+ "dependencies": {
15
+ "@gusto/baerly-storage": "workspace:*",
16
+ "react": "^19.0.0",
17
+ "react-dom": "^19.0.0",
18
+ "zod": "^4.4.3"
19
+ },
20
+ "devDependencies": {
21
+ "@cloudflare/vite-plugin": "^1.39.0",
22
+ "@cloudflare/workers-types": "^4",
23
+ "@types/node": "^24.0.0",
24
+ "@types/react": "^19.2.15",
25
+ "@types/react-dom": "^19.0.0",
26
+ "@vitejs/plugin-react": "^6.0.2",
27
+ "happy-dom": "^20.9.0",
28
+ "typescript": "^6.0.3",
29
+ "vite": "^8.0.14",
30
+ "vitest": "^4.1.7",
31
+ "wrangler": "^4.95.0"
32
+ },
33
+ "packageManager": "pnpm@11.1.2"
34
+ }
@@ -0,0 +1,15 @@
1
+ # pnpm 11 reads the postinstall-script allowlist only from this
2
+ # file: `package.json#pnpm.*` is no longer honoured. Without this
3
+ # map, `pnpm install` exits with `ERR_PNPM_IGNORED_BUILDS` for the
4
+ # Cloudflare-stack deps below.
5
+ #
6
+ # - `esbuild` / `workerd` ship working install scripts we want to run.
7
+ # - `sharp` is a transitive miniflare dep whose install script falls
8
+ # back to a node-gyp build on Node 24 (no prebuilt for our
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.
12
+ allowBuilds:
13
+ esbuild: true
14
+ workerd: true
15
+ sharp: false
@@ -0,0 +1,19 @@
1
+ // Example test for the shipped `notes` collection. Replace or
2
+ // delete when you change the schema in `baerly.config.ts` — the
3
+ // import on line below will stop typechecking once `notes` is
4
+ // gone.
5
+ import { test, expect } from "vitest";
6
+ import { Db, MemoryStorage } from "@gusto/baerly-storage";
7
+ import config from "../baerly.config.ts";
8
+
9
+ test("notes round-trip", async () => {
10
+ const db = Db.create({
11
+ storage: new MemoryStorage(),
12
+ app: "test",
13
+ tenant: "t",
14
+ config,
15
+ });
16
+ const { _id } = await db.collection("notes").insert({ body: "hello" });
17
+ const row = await db.collection("notes").get(_id);
18
+ expect(row?.body).toBe("hello");
19
+ });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Worker entry for react-cloudflare. `baerlyWorker(opts)` reads
3
+ * `opts.config.auth` to choose its verifier — the scaffold ships
4
+ * `auth: "none"`, so every request resolves to `config.tenant`.
5
+ * The schema declared in `baerly.config.ts:collections.notes.schema`
6
+ * runs server-side on every write. See AGENTS.md "Going to
7
+ * production" for the recipe to flip `auth` or wire a custom verifier.
8
+ */
9
+ import { baerlyWorker } from "@gusto/baerly-storage/cloudflare";
10
+ import config from "../../baerly.config.ts";
11
+
12
+ export default baerlyWorker(() => ({ config }));
@@ -0,0 +1,38 @@
1
+ import { BaerlyProvider, useMutation } from "@gusto/baerly-storage/client/react";
2
+ import { client } from "./client.ts";
3
+ import { NoteList } from "./NoteList.tsx";
4
+
5
+ const NewNoteForm = () => {
6
+ const [mutate, { isPending, error }] = useMutation();
7
+ return (
8
+ <form
9
+ className="new-note"
10
+ onSubmit={async (e) => {
11
+ e.preventDefault();
12
+ const form = e.currentTarget;
13
+ const body = String(new FormData(form).get("body")).trim();
14
+ if (body.length === 0) {
15
+ return;
16
+ }
17
+ await mutate((c) => c.collection("notes").insert({ body }));
18
+ form.reset();
19
+ }}
20
+ >
21
+ <textarea name="body" placeholder="Write a note…" rows={2} required />
22
+ <button type="submit" disabled={isPending}>
23
+ {isPending ? "Saving…" : "Add note"}
24
+ </button>
25
+ {error && <p className="error">Save failed: {error.message}</p>}
26
+ </form>
27
+ );
28
+ };
29
+
30
+ export const App = () => (
31
+ <BaerlyProvider client={client}>
32
+ <div className="app">
33
+ <h1>Notes</h1>
34
+ <NewNoteForm />
35
+ <NoteList />
36
+ </div>
37
+ </BaerlyProvider>
38
+ );
@@ -0,0 +1,93 @@
1
+ import { useState } from "react";
2
+ import { useMutation, useQuery } from "@gusto/baerly-storage/client/react";
3
+ import type { Note } from "../../baerly.config.ts";
4
+
5
+ const NoteRow = ({ note }: { note: Note }) => {
6
+ const [isEditing, setIsEditing] = useState(false);
7
+ const [body, setBody] = useState(note.body);
8
+ const [save, { isPending: isSaving, error: saveError }] = useMutation();
9
+ const [del, { isPending: isDeleting, error: deleteError }] = useMutation();
10
+ const error = saveError ?? deleteError;
11
+ return (
12
+ <li className="note-row">
13
+ {isEditing ? (
14
+ <textarea value={body} onChange={(e) => setBody(e.target.value)} rows={2} />
15
+ ) : (
16
+ <p className="note-body">{note.body}</p>
17
+ )}
18
+ <div className="actions">
19
+ {isEditing ? (
20
+ <>
21
+ <button
22
+ disabled={isSaving}
23
+ onClick={async () => {
24
+ await save((c) => c.collection("notes").update(note._id, { body }));
25
+ setIsEditing(false);
26
+ }}
27
+ >
28
+ {isSaving ? "Saving…" : "Save"}
29
+ </button>
30
+ <button
31
+ disabled={isSaving}
32
+ onClick={() => {
33
+ setBody(note.body);
34
+ setIsEditing(false);
35
+ }}
36
+ >
37
+ Cancel
38
+ </button>
39
+ </>
40
+ ) : (
41
+ <>
42
+ <button
43
+ onClick={() => {
44
+ setBody(note.body);
45
+ setIsEditing(true);
46
+ }}
47
+ >
48
+ Edit
49
+ </button>
50
+ <button
51
+ className="danger"
52
+ disabled={isDeleting}
53
+ onClick={async () => {
54
+ if (!window.confirm("Delete this note?")) {
55
+ return;
56
+ }
57
+ await del((c) => c.collection("notes").delete(note._id));
58
+ }}
59
+ >
60
+ {isDeleting ? "Deleting…" : "Delete"}
61
+ </button>
62
+ </>
63
+ )}
64
+ </div>
65
+ {error && <p className="error">{error.message}</p>}
66
+ </li>
67
+ );
68
+ };
69
+
70
+ export const NoteList = () => {
71
+ const result = useQuery((c) => c.collection("notes").all() as Promise<Note[]>, []);
72
+ if (result.status === "error") {
73
+ return <p className="error">Error: {result.error.message}</p>;
74
+ }
75
+ if (result.status === "loading") {
76
+ return <p>Loading…</p>;
77
+ }
78
+ // `result.status` is now "ok" or "refreshing" — `data` is `Note[]`.
79
+ // ("skipped" is unreachable: this useQuery never returns the skip sentinel.)
80
+ const rows = result.data ?? [];
81
+ if (rows.length === 0) {
82
+ return <p>No notes yet. Add one above.</p>;
83
+ }
84
+ // Newest first — UUIDv7 `_id`s sort by server mint time descending.
85
+ const sorted = rows.toSorted((a, b) => b._id.localeCompare(a._id));
86
+ return (
87
+ <ul className="note-list">
88
+ {sorted.map((n) => (
89
+ <NoteRow key={n._id} note={n} />
90
+ ))}
91
+ </ul>
92
+ );
93
+ };
@@ -0,0 +1,13 @@
1
+ import { createBaerlyClient } from "@gusto/baerly-storage/client";
2
+ import config from "../../baerly.config.ts";
3
+
4
+ // Same-origin baseUrl works in both dev and production. With
5
+ // `auth: "none"` in baerly.config.ts (the scaffold default), this
6
+ // file never sends an `Authorization` header and the adapter pins
7
+ // every request to `config.tenant`. When you flip `auth` for
8
+ // production, the AGENTS.md "Going to production" recipe shows
9
+ // where the token / cookie comes from.
10
+ export const client = createBaerlyClient({
11
+ baseUrl: "",
12
+ config,
13
+ });
@@ -0,0 +1,14 @@
1
+ import { StrictMode } from "react";
2
+ import { createRoot } from "react-dom/client";
3
+ import { App } from "./App.tsx";
4
+ import "./styles.css";
5
+
6
+ const root = document.getElementById("root");
7
+ if (root === null) {
8
+ throw new Error("No #root element");
9
+ }
10
+ createRoot(root).render(
11
+ <StrictMode>
12
+ <App />
13
+ </StrictMode>,
14
+ );
@@ -0,0 +1,57 @@
1
+ body {
2
+ font-family: system-ui, sans-serif;
3
+ margin: 0;
4
+ }
5
+
6
+ .app {
7
+ padding: 24px;
8
+ max-width: 720px;
9
+ margin: 0 auto;
10
+ }
11
+
12
+ .app h1 {
13
+ margin: 0 0 24px;
14
+ }
15
+
16
+ .new-note {
17
+ margin-bottom: 24px;
18
+ }
19
+
20
+ .new-note textarea,
21
+ .note-row textarea {
22
+ display: block;
23
+ width: 100%;
24
+ resize: vertical;
25
+ }
26
+
27
+ .new-note button {
28
+ margin-top: 8px;
29
+ }
30
+
31
+ .note-list {
32
+ list-style: none;
33
+ padding: 0;
34
+ }
35
+
36
+ .note-row {
37
+ padding: 12px 0;
38
+ border-bottom: 1px solid #eee;
39
+ }
40
+
41
+ .note-body {
42
+ margin: 0;
43
+ white-space: pre-wrap;
44
+ }
45
+
46
+ .actions {
47
+ margin-top: 8px;
48
+ }
49
+
50
+ .actions button + button {
51
+ margin-left: 8px;
52
+ }
53
+
54
+ .error,
55
+ .danger {
56
+ color: crimson;
57
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2024",
4
+ "lib": ["ES2024", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "allowImportingTsExtensions": true,
8
+ "noEmit": true,
9
+
10
+ "strict": true,
11
+ "noUncheckedIndexedAccess": true,
12
+ "noImplicitOverride": true,
13
+ "noImplicitReturns": true,
14
+ "noPropertyAccessFromIndexSignature": true,
15
+ "noFallthroughCasesInSwitch": true,
16
+ "noUnusedLocals": true,
17
+ "noUnusedParameters": true,
18
+ "verbatimModuleSyntax": true,
19
+ "isolatedModules": true,
20
+ "erasableSyntaxOnly": true,
21
+
22
+ "esModuleInterop": true,
23
+ "skipLibCheck": true,
24
+ "jsx": "react-jsx",
25
+ "types": ["vite/client"],
26
+ "composite": true
27
+ },
28
+ "include": ["src/web/**/*", "uint8array-base64.d.ts", "baerly.config.ts"]
29
+ }
@@ -0,0 +1,9 @@
1
+ // Stub — TS picks up the referenced projects below.
2
+ // `tsconfig.app.json` covers the SPA (DOM); `tsconfig.worker.json`
3
+ // covers the Worker entry (workerd). Tests at the repo root match
4
+ // `vitest.config.ts:test.include` (e.g. `*.test.ts`); they don't
5
+ // belong to any tsconfig — vitest type-checks them via its own pipe.
6
+ {
7
+ "files": [],
8
+ "references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.worker.json" }]
9
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2024",
4
+ "lib": ["ES2024", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "allowImportingTsExtensions": true,
8
+ "noEmit": true,
9
+
10
+ "strict": true,
11
+ "noUncheckedIndexedAccess": true,
12
+ "noImplicitOverride": true,
13
+ "noImplicitReturns": true,
14
+ "noPropertyAccessFromIndexSignature": true,
15
+ "noFallthroughCasesInSwitch": true,
16
+ "noUnusedLocals": true,
17
+ "noUnusedParameters": true,
18
+ "verbatimModuleSyntax": true,
19
+ "isolatedModules": true,
20
+ "erasableSyntaxOnly": true,
21
+
22
+ "esModuleInterop": true,
23
+ "skipLibCheck": true,
24
+ "types": ["@cloudflare/workers-types", "node"],
25
+ "composite": true
26
+ },
27
+ "include": ["src/server/**/*", "uint8array-base64.d.ts", "baerly.config.ts"]
28
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * TC39 Stage-4 base64 codec methods — Node 22+, Bun, Workerd. Delete
3
+ * when TypeScript accepts `esnext.typedarrays` in `--lib`.
4
+ */
5
+ interface Uint8Array<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> {
6
+ toBase64(options?: { alphabet?: "base64" | "base64url"; omitPadding?: boolean }): string;
7
+ }
8
+ interface Uint8ArrayConstructor {
9
+ fromBase64(
10
+ input: string,
11
+ options?: {
12
+ alphabet?: "base64" | "base64url";
13
+ lastChunkHandling?: "loose" | "strict" | "stop-before-partial";
14
+ },
15
+ ): Uint8Array;
16
+ }
@@ -0,0 +1,7 @@
1
+ import { cloudflare } from "@cloudflare/vite-plugin";
2
+ import react from "@vitejs/plugin-react";
3
+ import { defineConfig } from "vite";
4
+
5
+ export default defineConfig({
6
+ plugins: [react(), cloudflare()],
7
+ });
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from "vitest/config";
2
+
3
+ // Standalone — `vite.config.ts` loads `@cloudflare/vite-plugin`, which
4
+ // rejects vitest's pool/environment combo. Add `@cloudflare/vitest-pool-workers`
5
+ // here if you want Worker-side integration tests.
6
+ export default defineConfig({
7
+ test: {
8
+ environment: "node",
9
+ include: ["src/**/*.test.{ts,tsx}", "*.test.ts"],
10
+ },
11
+ });
@@ -0,0 +1,27 @@
1
+ {
2
+ // Cloudflare Worker manifest. See `AGENTS.md` for what each field
3
+ // drives (R2 binding, assets, vars, cron, observability) and how
4
+ // the verifier consumes the vars.
5
+ "$schema": "node_modules/wrangler/config-schema.json",
6
+ "name": "react-cloudflare",
7
+ "main": "./src/server/index.ts",
8
+ "compatibility_date": "2026-05-01",
9
+ "compatibility_flags": ["nodejs_compat"],
10
+
11
+ "r2_buckets": [
12
+ {
13
+ "binding": "BUCKET",
14
+ "bucket_name": "react-cloudflare",
15
+ },
16
+ ],
17
+
18
+ "assets": {
19
+ "directory": "./dist/client",
20
+ "not_found_handling": "single-page-application",
21
+ },
22
+
23
+ "vars": {
24
+ "APP": "react-cloudflare",
25
+ "TENANT": "react-demo",
26
+ },
27
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "renames": [
3
+ { "from": "react-node", "fromKey": "appName" },
4
+ { "from": "react-demo", "fromKey": "tenant" }
5
+ ],
6
+ "excludePaths": [".baerly/scaffold.json"],
7
+ "excludeNames": ["node_modules", "dist", ".baerly-data", ".DS_Store", "*.tsbuildinfo"],
8
+ "dropDevDeps": [],
9
+ "copies": [
10
+ { "from": "AGENTS.md", "to": "CLAUDE.md" },
11
+ { "from": ".env.example", "to": ".env" }
12
+ ]
13
+ }
@@ -0,0 +1,14 @@
1
+ # Storage credentials (AWS S3 default; R2 when R2_ACCOUNT_ID is set).
2
+ # For Minio / GCS, edit `src/server/index.ts` to use the matching
3
+ # factory from `baerly-storage/node` (`minioStorage` / `gcsStorage`).
4
+ AWS_ACCESS_KEY_ID=
5
+ AWS_SECRET_ACCESS_KEY=
6
+ AWS_REGION=us-east-1
7
+ BUCKET=
8
+ # Set to your Cloudflare R2 account ID (left half of the
9
+ # https://<account>.r2.cloudflarestorage.com endpoint) to switch
10
+ # storage from AWS S3 to R2. Leave unset for AWS S3.
11
+ # R2_ACCOUNT_ID=
12
+
13
+ # Server
14
+ PORT=8080