You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Optional ESLint, TS, directories, and deploy presets
37
+
- Optional ESLint, TS, directories, and deploy presets
38
+
_(For the Cloudflare adapter template, ESLint/TS are effectively skipped; you get a JS Worker-focused boilerplate.)_
34
39
35
-
> **Note:** The **source** (`src-api/`) and **output** (`api-out/`) directories are defaults. You can **customize** these during scaffolding or later in your [Configuration](../config).
40
+
> **Note:** The **source** (`src-api/`) and **output** (`api-out/`) directories are defaults for the core templates.
41
+
> You can **customize** these during scaffolding or later in your [Configuration](../config).
42
+
> For the Cloudflare adapter template, `src-api/` is still the default, but the JSON is pushed to **R2** instead of a local `api-out/` for hosting.
- Optional ESLint, TS, directories, and deploy presets
50
+
- Optional ESLint, TS, directories, and deploy presets
51
+
_(ESLint/TS are disabled for the Cloudflare adapter template; it ships ready-to-run JS Worker boilerplate.)_
49
52
50
-
The dev server watches your **source directory** (default `src-api/`, configurable via [Configuration](./config)) and serves a local **UI** at `/_ui` with a live manifest, JSON previews, and copy-ready code snippets.
53
+
The dev server for normal templates watches your **source directory** (default `src-api/`, configurable via [Configuration](./config)) and serves a local **UI** at `/_ui` with a live manifest, JSON previews, and copy-ready code snippets.
54
+
55
+
---
56
+
57
+
## 1b) Using the Cloudflare Worker adapter (serverless mode)
58
+
59
+
If you pick the **`cloudflare-adapter`** template, `create-statikapi` scaffolds:
60
+
61
+
- A **Cloudflare Worker** wired to:
62
+
-**R2** (stores built JSON)
63
+
-**KV** (stores the manifest)
64
+
- A **build webhook endpoint** on the Worker (`/build`)
65
+
- A default **JS-only** boilerplate (no TypeScript / ESLint)
66
+
67
+
From there you can:
68
+
69
+
- Run the bundled dev commands to iterate locally
70
+
- Deploy the Worker to Cloudflare
71
+
-**Trigger rebuilds via HTTP**:
72
+
-`POST /build` — rebuild **all routes**
73
+
-`POST /build?route=/users/1` — rebuild just that route
74
+
75
+
Authentication is handled via a **`STATIK_BUILD_TOKEN`** env var on the Worker.
76
+
Clients include this token in requests (see [Cloudflare Worker + R2 Adapter](./serverless/cloudflare-adapter) for full details and `curl` examples).
77
+
78
+
This mode is ideal when:
79
+
80
+
- You want StatikAPI’s DX, but need a **serverless endpoint** instead of raw static hosting
81
+
- Your data changes frequently and you want to **trigger updates via webhooks** from other systems
- Learn the **Routing** model (static, dynamic, catch-all, remote)
143
174
- Use **data()** and **paths()** to shape your endpoints
175
+
- Explore the **[Cloudflare Worker + R2 adapter](./serverless/cloudflare-adapter)** if you want StatikAPI behind a serverless Worker with a build webhook
0 commit comments