devflare 1.0.0-next.42 → 1.0.0-next.44
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/LLM.md +1342 -1
- package/dist/_chunks/{account-BtWcv3X9.js → account-Cdo_cRNv.js} +1 -1
- package/dist/_chunks/{build-D1l6a5Il.js → build-MzQbenXE.js} +1 -1
- package/dist/_chunks/{build-artifacts-BUaq16e4.js → build-artifacts-tD45Rwmx.js} +4 -4
- package/dist/_chunks/{cli-CgFqrDZd.js → cli-BiDDz-RY.js} +12 -12
- package/dist/_chunks/{command-utils-BsfkmTqh.js → command-utils-C48hJMln.js} +1 -1
- package/dist/_chunks/{compiler-uoyAQ8zW.js → compiler-Dc97FkBg.js} +80 -15
- package/dist/_chunks/{config-D5u-bEkn.js → config-DQ_uWv37.js} +3 -3
- package/dist/_chunks/{config-path-DCPto4XB.js → config-path-ePwIvHNX.js} +1 -1
- package/dist/_chunks/{deploy-DIDoW5u1.js → deploy-BmtstRbc.js} +6 -6
- package/dist/_chunks/{dev-BTSSETUX.js → dev-wVHYCbZF.js} +19 -10
- package/dist/_chunks/{doctor-C0g8X36G.js → doctor-lFlh-olK.js} +2 -2
- package/dist/_chunks/{family-DXC5SdFK.js → family-Dfb9VR9g.js} +1 -1
- package/dist/_chunks/{loader-DLXO60RO.js → loader-RZhqzsRJ.js} +4 -4
- package/dist/_chunks/{local-secrets-DMmEOygL.js → local-secrets-DMPkmOn3.js} +1 -1
- package/dist/_chunks/{local-workflow-entrypoints-Wip3o1u8.js → local-workflow-entrypoints-Cq_WJajd.js} +1 -1
- package/dist/_chunks/{login-BmnDzDlH.js → login-DnyfffOC.js} +1 -1
- package/dist/_chunks/{preview-BhqDmq8I.js → preview-C3Cdr8an.js} +9 -3
- package/dist/_chunks/{preview-resources-DdXj8LMM.js → preview-resources-xziKCynb.js} +5 -4
- package/dist/_chunks/{previews-Dlr13x5M.js → previews-wI-pW6HM.js} +7 -7
- package/dist/_chunks/{productions-D3AnOHac.js → productions-BpROdhLN.js} +3 -3
- package/dist/_chunks/{routes-BWi7h2xb.js → routes-5OnFhKR2.js} +18 -5
- package/dist/_chunks/{schema-normalization-DWVleVxo.js → schema-normalization-BCwTLTGp.js} +196 -13
- package/dist/_chunks/{secrets-70eN0Q6C.js → secrets-DIpJGe6C.js} +1 -1
- package/dist/_chunks/{types-BgA5Hb4B.js → types-Zn9vyUGA.js} +11 -3
- package/dist/_chunks/{vite-BszZvrKL.js → vite-DLUELS0D.js} +5 -5
- package/dist/_chunks/{worker-CS1jgNFE.js → worker-rL5udcl9.js} +4 -4
- package/dist/bridge/miniflare.d.ts.map +1 -1
- package/dist/browser.d.ts +818 -36
- package/dist/browser.d.ts.map +1 -1
- package/dist/cli/commands/type-generation/generator.d.ts +12 -3
- package/dist/cli/commands/type-generation/generator.d.ts.map +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/config/compiler/bindings.d.ts.map +1 -1
- package/dist/config/compiler/do-workers.d.ts.map +1 -1
- package/dist/config/compiler/types.d.ts +28 -0
- package/dist/config/compiler/types.d.ts.map +1 -1
- package/dist/config/deploy-resources.d.ts.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/preview-resources.d.ts +1 -1
- package/dist/config/preview-resources.d.ts.map +1 -1
- package/dist/config/preview.d.ts.map +1 -1
- package/dist/config/schema-bindings.d.ts +544 -14
- package/dist/config/schema-bindings.d.ts.map +1 -1
- package/dist/config/schema-env.d.ts +572 -24
- package/dist/config/schema-env.d.ts.map +1 -1
- package/dist/config/schema-normalization.d.ts +82 -1
- package/dist/config/schema-normalization.d.ts.map +1 -1
- package/dist/config/schema-types-bindings-platform.d.ts +130 -0
- package/dist/config/schema-types-bindings-platform.d.ts.map +1 -1
- package/dist/config/schema-types-bindings-resources.d.ts +220 -3
- package/dist/config/schema-types-bindings-resources.d.ts.map +1 -1
- package/dist/config/schema-types-bindings.d.ts +42 -3
- package/dist/config/schema-types-bindings.d.ts.map +1 -1
- package/dist/config/schema.d.ts +1035 -57
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config-entry.js +1 -1
- package/dist/dev-server/miniflare-bindings.d.ts +6 -0
- package/dist/dev-server/miniflare-bindings.d.ts.map +1 -1
- package/dist/dev-server/miniflare-dev-config.d.ts.map +1 -1
- package/dist/dev-server/miniflare-worker-config.d.ts +5 -1
- package/dist/dev-server/miniflare-worker-config.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/sveltekit/index.js +3 -3
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +168 -10
- package/dist/test/offline-bindings.d.ts +5 -3
- package/dist/test/offline-bindings.d.ts.map +1 -1
- package/dist/test/resolve-service-bindings.d.ts.map +1 -1
- package/dist/test/simple-context-mfconfig.d.ts.map +1 -1
- package/dist/test/utilities/stream-flagship.d.ts +27 -0
- package/dist/test/utilities/stream-flagship.d.ts.map +1 -0
- package/dist/test/utilities.d.ts +1 -0
- package/dist/test/utilities.d.ts.map +1 -1
- package/dist/vite/index.js +1 -1
- package/package.json +1 -1
package/LLM.md
CHANGED
|
@@ -13,7 +13,7 @@ It is meant to read like a proper markdown handbook rather than a second source
|
|
|
13
13
|
- Links use the same `/docs/...` routes as the documentation site.
|
|
14
14
|
|
|
15
15
|
## Documentation map
|
|
16
|
-
This export covers
|
|
16
|
+
This export covers 163 pages across 5 top-level groups.
|
|
17
17
|
|
|
18
18
|
### Quickstart
|
|
19
19
|
See why Devflare exists, build the smallest safe first worker, and move into routes, bindings, previews, and tests when the app needs them.
|
|
@@ -249,6 +249,30 @@ Use the per-binding guides for the exact authoring, runtime, testing, preview, a
|
|
|
249
249
|
- [Testing Containers](/docs/bindings/containers/testing) — Test Containers by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default.
|
|
250
250
|
- [Containers example](/docs/bindings/containers/example) — A compact Containers recipe with config and worker usage in one application path.
|
|
251
251
|
|
|
252
|
+
- **Stream** — Cloudflare Stream binding docs with singleton config, a local Miniflare-backed simulator, and clear video-upload fidelity boundaries.
|
|
253
|
+
- [Stream](/docs/bindings/stream) — Add the Stream config, call `StreamBinding` from worker code, and start with the local test path Devflare supports.
|
|
254
|
+
- [Stream internals](/docs/bindings/stream/internals) — Stream compiles from `bindings.stream` to Wrangler `stream`, with local/test behavior called out explicitly.
|
|
255
|
+
- [Testing Stream](/docs/bindings/stream/testing) — Test Stream by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default.
|
|
256
|
+
- [Stream example](/docs/bindings/stream/example) — A compact Stream recipe with config and worker usage in one application path.
|
|
257
|
+
|
|
258
|
+
- **VPC Services** — VPC service bindings that reach a private service through a Cloudflare VPC connectivity service.
|
|
259
|
+
- [VPC Services](/docs/bindings/vpc-services) — Add the VPC Services config, call a VPC service `Fetcher` from worker code, and start with the local test path Devflare supports.
|
|
260
|
+
- [VPC Services internals](/docs/bindings/vpc-services/internals) — VPC Services compiles from `bindings.vpcServices` to Wrangler `vpc_services`, with local/test behavior called out explicitly.
|
|
261
|
+
- [Testing VPC Services](/docs/bindings/vpc-services/testing) — Test VPC Services by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default.
|
|
262
|
+
- [VPC Services example](/docs/bindings/vpc-services/example) — A compact VPC Services recipe with config and worker usage in one application path.
|
|
263
|
+
|
|
264
|
+
- **VPC Networks** — VPC network bindings that route traffic through a Cloudflare Tunnel or a network ID.
|
|
265
|
+
- [VPC Networks](/docs/bindings/vpc-networks) — Add the VPC Networks config, call a VPC network `Fetcher` from worker code, and start with the local test path Devflare supports.
|
|
266
|
+
- [VPC Networks internals](/docs/bindings/vpc-networks/internals) — VPC Networks compiles from `bindings.vpcNetworks` to Wrangler `vpc_networks`, with local/test behavior called out explicitly.
|
|
267
|
+
- [Testing VPC Networks](/docs/bindings/vpc-networks/testing) — Test VPC Networks by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default.
|
|
268
|
+
- [VPC Networks example](/docs/bindings/vpc-networks/example) — A compact VPC Networks recipe with config and worker usage in one application path.
|
|
269
|
+
|
|
270
|
+
- **Flagship** — Flagship feature-flag bindings for reading feature flags from Workers, with deterministic pure mocks that return configured flag values.
|
|
271
|
+
- [Flagship](/docs/bindings/flagship) — Add the Flagship config, call `Flagship` from worker code, and start with the local test path Devflare supports.
|
|
272
|
+
- [Flagship internals](/docs/bindings/flagship/internals) — Flagship compiles from `bindings.flagship` to Wrangler `flagship`, with local/test behavior called out explicitly.
|
|
273
|
+
- [Testing Flagship](/docs/bindings/flagship/testing) — Test Flagship by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default.
|
|
274
|
+
- [Flagship example](/docs/bindings/flagship/example) — A compact Flagship recipe with config and worker usage in one application path.
|
|
275
|
+
|
|
252
276
|
## Full documentation
|
|
253
277
|
|
|
254
278
|
### Why Devflare feels better than stitching Cloudflare Worker workflows together by hand
|
|
@@ -340,6 +364,10 @@ Every native binding or platform lane in the binding docs is listed here with it
|
|
|
340
364
|
- **Images** — Native singleton config, Miniflare image bindings, and a low-fidelity deterministic pure mock cover Worker `info()`/transform chain shapes. The named gap is the hosted storage API (`hosted.image()` / `.upload()` / `.list()`), which throws locally. Hosted storage, variants, delivery rules, billing, and final transform fidelity remain remote. ([link](/docs/bindings/images))
|
|
341
365
|
- **Media Transformations** — Native config, Miniflare media bindings, and a deterministic passthrough pure mock cover Worker media transform chain shapes locally. Real codecs, output fidelity, duration handling, cache behavior, and billing remain hosted Cloudflare behavior, so the local contract is narrower than the deployed product. ([link](/docs/bindings/media-transformations))
|
|
342
366
|
- **Artifacts** — Native config and in-memory repo or token fixtures are supported for app flow. Durable storage, Git-over-HTTPS remotes, namespace creation, and permissions are Cloudflare-owned. ([link](/docs/bindings/artifacts))
|
|
367
|
+
- **Stream** — Native singleton config, a Miniflare-backed local Stream simulator, and a deterministic pure mock cover the binding shape (video listing and per-video metadata access). Real video upload, transcode, delivery, signed tokens, and billing remain hosted Cloudflare behavior, so the local contract is narrower than the deployed product. ([link](/docs/bindings/stream))
|
|
368
|
+
- **VPC Services** — Native config and deploy emission to `vpc_services` are supported. There is no local simulation: Miniflare wires VPC services only as a remote proxy client, so the private connectivity service and its upstream are Cloudflare-owned. Inject a fake binding for pure tests or use remote mode. ([link](/docs/bindings/vpc-services))
|
|
369
|
+
- **VPC Networks** — Native config (Tunnel ID or network ID) and deploy emission to `vpc_networks` are supported. There is no local simulation: Miniflare wires VPC networks only as a remote proxy client, so the Tunnel and private network path are Cloudflare-owned. Inject a fake binding for pure tests or use remote mode. ([link](/docs/bindings/vpc-networks))
|
|
370
|
+
- **Flagship** — Native config, deploy emission to `flagship`, and a deterministic pure mock (`createMockFlagshipBinding({ flags })`) cover the local app loop for reading feature flags. Miniflare's Flagship plugin returns each call's default value and ignores the flag key, so it does not evaluate flag rules locally; real targeting-rule evaluation, flag management, and remote flag state remain Cloudflare-owned. ([link](/docs/bindings/flagship))
|
|
343
371
|
- **Containers** — Native top-level container config has full local support through Docker or Podman: Devflare can build Dockerfile paths offline-first, run prebuilt image tags, and interact with launched instances. Deployed rollout, registry availability, SSH, scaling, and hosted platform behavior remain Cloudflare-owned. ([link](/docs/bindings/containers))
|
|
344
372
|
|
|
345
373
|
#### What Devflare adds on top of raw Cloudflare workflows
|
|
@@ -4578,6 +4606,10 @@ That is great once you already opened the right binding page. This index is for
|
|
|
4578
4606
|
- **Testing Media Transformations** — Test Media Transformations by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default. Open the Media Transformations overview first when you need the full binding story, or jump straight here when the only open question is how to test it. ([link](/docs/bindings/media-transformations/testing))
|
|
4579
4607
|
- **Testing Artifacts** — Test Artifacts by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default. Open the Artifacts overview first when you need the full binding story, or jump straight here when the only open question is how to test it. ([link](/docs/bindings/artifacts/testing))
|
|
4580
4608
|
- **Testing Containers** — Test Containers by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default. Open the Containers overview first when you need the full binding story, or jump straight here when the only open question is how to test it. ([link](/docs/bindings/containers/testing))
|
|
4609
|
+
- **Testing Stream** — Test Stream by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default. Open the Stream overview first when you need the full binding story, or jump straight here when the only open question is how to test it. ([link](/docs/bindings/stream/testing))
|
|
4610
|
+
- **Testing VPC Services** — Test VPC Services by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default. Open the VPC Services overview first when you need the full binding story, or jump straight here when the only open question is how to test it. ([link](/docs/bindings/vpc-services/testing))
|
|
4611
|
+
- **Testing VPC Networks** — Test VPC Networks by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default. Open the VPC Networks overview first when you need the full binding story, or jump straight here when the only open question is how to test it. ([link](/docs/bindings/vpc-networks/testing))
|
|
4612
|
+
- **Testing Flagship** — Test Flagship by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default. Open the Flagship overview first when you need the full binding story, or jump straight here when the only open question is how to test it. ([link](/docs/bindings/flagship/testing))
|
|
4581
4613
|
|
|
4582
4614
|
#### The testing posture is not identical for every binding
|
|
4583
4615
|
|
|
@@ -4610,6 +4642,10 @@ That is great once you already opened the right binding page. This index is for
|
|
|
4610
4642
|
| Media Transformations | Full local support through Miniflare media bindings and deterministic pure mocks for transform chains | `createTestContext()` or `createOfflineEnv()` with media fixtures |
|
|
4611
4643
|
| Artifacts | Offline-fixture: repo metadata and token flows can be modeled in memory, not as real Git remotes | `createOfflineEnv()` with artifact fixtures |
|
|
4612
4644
|
| Containers | Offline-native only when an explicit Docker/Podman engine is available and the image can run without pulling | `devflare/test` containers helpers guarded by `shouldSkip.containers` |
|
|
4645
|
+
| Stream | Full local support through the native Miniflare Stream plugin (a local StreamObject backed by disk persistence) plus a deterministic pure mock for app-level tests | `createTestContext()` or `createOfflineEnv()` |
|
|
4646
|
+
| VPC Services | Remote boundary: Miniflare wires VPC services only as a remote proxy client, so there is no offline simulation | a deployed or remote-mode test against the real VPC service |
|
|
4647
|
+
| VPC Networks | Remote boundary: Miniflare wires VPC networks only as a remote proxy client, so there is no offline simulation | a deployed or remote-mode test against the real VPC network |
|
|
4648
|
+
| Flagship | Miniflare's Flagship plugin returns each call's default value locally and ignores the flag key (it does not evaluate flag rules), while Devflare's deterministic pure mock (createMockFlagshipBinding({ flags })) returns configured flag values, falling back to the default | `createTestContext()` or `createOfflineEnv()` |
|
|
4613
4649
|
|
|
4614
4650
|
> **Warning — Different defaults are a good thing**
|
|
4615
4651
|
>
|
|
@@ -4755,6 +4791,8 @@ The `devflare/test` entrypoint intentionally has multiple lanes: runtime-shaped
|
|
|
4755
4791
|
| `createMockPipeline` | Mock a Pipelines binding. |
|
|
4756
4792
|
| `createMockImagesBinding` | Mock Images chains. |
|
|
4757
4793
|
| `createMockMediaBinding` | Mock Media Transformation chains. |
|
|
4794
|
+
| `createMockStreamBinding` | Mock a Stream binding. |
|
|
4795
|
+
| `createMockFlagshipBinding` | Mock a Flagship feature-flag binding. |
|
|
4758
4796
|
| `createMockArtifacts` | Mock Artifacts repo APIs. |
|
|
4759
4797
|
| `createMockSecretsStoreSecret` | Mock a Secrets Store secret. |
|
|
4760
4798
|
| `createMockEnv` | Create a pure env with selected mock bindings. |
|
|
@@ -15964,3 +16002,1306 @@ export async function fetch(request: Request): Promise<Response> {
|
|
|
15964
16002
|
> **Important — Thread this into the next recipe**
|
|
15965
16003
|
>
|
|
15966
16004
|
> Once this smallest path works, add routing, generated types, and feature-specific abstraction in that order.
|
|
16005
|
+
|
|
16006
|
+
---
|
|
16007
|
+
|
|
16008
|
+
### Use Stream in a Worker
|
|
16009
|
+
|
|
16010
|
+
> Add the Stream config, call `StreamBinding` from worker code, and start with the local test path Devflare supports.
|
|
16011
|
+
|
|
16012
|
+
| Field | Value |
|
|
16013
|
+
| --- | --- |
|
|
16014
|
+
| Route | [`/docs/bindings/stream`](/docs/bindings/stream) |
|
|
16015
|
+
| Group | Bindings |
|
|
16016
|
+
| Navigation title | Stream |
|
|
16017
|
+
| Eyebrow | Binding reference |
|
|
16018
|
+
|
|
16019
|
+
Start with the config, wire the binding into worker code, then use the support section to decide whether local tests or Cloudflare-backed tests fit.
|
|
16020
|
+
|
|
16021
|
+
#### At a glance
|
|
16022
|
+
|
|
16023
|
+
| Fact | Value |
|
|
16024
|
+
| --- | --- |
|
|
16025
|
+
| Config key | `bindings.stream` |
|
|
16026
|
+
| Authoring shape | `Record<string, true \| { remote? }>` |
|
|
16027
|
+
| Best for | video listing and per-video metadata paths where the Worker calls the Stream binding |
|
|
16028
|
+
|
|
16029
|
+
#### Add the binding to config
|
|
16030
|
+
|
|
16031
|
+
Add `bindings.stream` to `devflare.config.ts`, then use the generated env binding from Worker code.
|
|
16032
|
+
|
|
16033
|
+
Keep the first version close to the route or handler that needs it; move to a helper only after the shape is obvious.
|
|
16034
|
+
|
|
16035
|
+
##### Example — Smallest Stream config
|
|
16036
|
+
|
|
16037
|
+
```ts
|
|
16038
|
+
import { defineConfig } from 'devflare/config'
|
|
16039
|
+
|
|
16040
|
+
export default defineConfig({
|
|
16041
|
+
name: 'stream-worker',
|
|
16042
|
+
bindings: {
|
|
16043
|
+
stream: {
|
|
16044
|
+
STREAM: true
|
|
16045
|
+
}
|
|
16046
|
+
}
|
|
16047
|
+
})
|
|
16048
|
+
```
|
|
16049
|
+
|
|
16050
|
+
#### Use the binding from application code
|
|
16051
|
+
|
|
16052
|
+
After Devflare generates the worker env, import `env` from `devflare/runtime` and keep the first Stream path close to the route, handler, or service method that needs it.
|
|
16053
|
+
|
|
16054
|
+
Keep this first path small enough that the config, env binding, and user-visible behavior are easy to review together.
|
|
16055
|
+
|
|
16056
|
+
##### Example — List Stream videos
|
|
16057
|
+
|
|
16058
|
+
```ts
|
|
16059
|
+
import { env } from 'devflare/runtime'
|
|
16060
|
+
|
|
16061
|
+
export async function fetch(): Promise<Response> {
|
|
16062
|
+
const videos = await env.STREAM.videos.list()
|
|
16063
|
+
|
|
16064
|
+
return Response.json({ count: videos.length })
|
|
16065
|
+
}
|
|
16066
|
+
```
|
|
16067
|
+
|
|
16068
|
+
#### Local and Remote Support
|
|
16069
|
+
|
|
16070
|
+
Devflare has a real lane for Stream, but the local contract is intentionally narrower than Cloudflare's hosted product. The docs call out the supported local path and the remote boundary separately.
|
|
16071
|
+
|
|
16072
|
+
Full local support through the native Miniflare Stream plugin (a local StreamObject backed by disk persistence) plus a deterministic pure mock for app-level tests. Use the documented local lane only for the behavior Devflare explicitly models, and keep the narrower boundary visible in code review.
|
|
16073
|
+
|
|
16074
|
+
Use Cloudflare when the assertion depends on cloudflare-hosted product behavior rather than the app calling the binding correctly. This is the lane for full Stream product fidelity, remote state, lifecycle behavior, and platform-specific limits.
|
|
16075
|
+
|
|
16076
|
+
#### When this binding fits best
|
|
16077
|
+
|
|
16078
|
+
##### Key points
|
|
16079
|
+
|
|
16080
|
+
- Use Stream when video listing and per-video metadata paths where the worker calls the stream binding.
|
|
16081
|
+
- Keep binding names stable and uppercase in examples so generated Env declarations remain predictable.
|
|
16082
|
+
- Prefer Devflare native config while it covers the feature; use `wrangler.passthrough` only for unsupported Wrangler-only fields.
|
|
16083
|
+
|
|
16084
|
+
#### Testing path
|
|
16085
|
+
|
|
16086
|
+
##### Key points
|
|
16087
|
+
|
|
16088
|
+
- Start with `createTestContext()` or `createOfflineEnv()` for config-backed local worker tests.
|
|
16089
|
+
- Use `createMockStreamBinding()` / `createMockEnv({ stream })` for small unit tests that only need deterministic application behavior.
|
|
16090
|
+
- Use Cloudflare-backed tests when the assertion depends on hosted platform behavior, account state, limits, billing, or production routing.
|
|
16091
|
+
|
|
16092
|
+
#### Open the next page when you need it
|
|
16093
|
+
|
|
16094
|
+
##### Highlights
|
|
16095
|
+
|
|
16096
|
+
- **Stream internals** — Check emitted Wrangler `stream`, preview behavior, and Cloudflare-specific details. ([link](/docs/bindings/stream/internals))
|
|
16097
|
+
- **Testing Stream** — Pick the `createTestContext()` or `createOfflineEnv()` path first, then move to remote checks only when the test needs them. ([link](/docs/bindings/stream/testing))
|
|
16098
|
+
- **Stream example** — Copy a fuller application path when the quick example is too small. ([link](/docs/bindings/stream/example))
|
|
16099
|
+
|
|
16100
|
+
---
|
|
16101
|
+
|
|
16102
|
+
### How Devflare wires Stream from config to runtime
|
|
16103
|
+
|
|
16104
|
+
> Stream compiles from `bindings.stream` to Wrangler `stream`, with local/test behavior called out explicitly.
|
|
16105
|
+
|
|
16106
|
+
| Field | Value |
|
|
16107
|
+
| --- | --- |
|
|
16108
|
+
| Route | [`/docs/bindings/stream/internals`](/docs/bindings/stream/internals) |
|
|
16109
|
+
| Group | Bindings |
|
|
16110
|
+
| Navigation title | Stream internals |
|
|
16111
|
+
| Eyebrow | Under the hood |
|
|
16112
|
+
|
|
16113
|
+
Use this page when you need emitted config, preview behavior, or Cloudflare-specific limits. The overview and example pages stay focused on everyday app code.
|
|
16114
|
+
|
|
16115
|
+
#### At a glance
|
|
16116
|
+
|
|
16117
|
+
| Fact | Value |
|
|
16118
|
+
| --- | --- |
|
|
16119
|
+
| Normalization | Devflare normalizes `bindings.stream` before emitting Wrangler `stream` |
|
|
16120
|
+
| Compile target | Wrangler `stream` |
|
|
16121
|
+
| Preview note | Cloudflare owns real video upload, transcode, delivery, signed tokens, and billing; the local mock only models the binding shape. |
|
|
16122
|
+
|
|
16123
|
+
#### How authored config becomes Wrangler config
|
|
16124
|
+
|
|
16125
|
+
The authored config stays camelCase and project-oriented. The compiler translates that into the Wrangler keys Cloudflare expects.
|
|
16126
|
+
|
|
16127
|
+
The emitted output is shown here so the usage pages do not have to explain compiler details.
|
|
16128
|
+
|
|
16129
|
+
##### Example — Stream config and emitted Wrangler output
|
|
16130
|
+
|
|
16131
|
+
Use this when you need to check how the Devflare config becomes Wrangler-compatible config.
|
|
16132
|
+
|
|
16133
|
+
###### File — devflare.config.ts
|
|
16134
|
+
|
|
16135
|
+
```ts
|
|
16136
|
+
import { defineConfig } from 'devflare/config'
|
|
16137
|
+
|
|
16138
|
+
export default defineConfig({
|
|
16139
|
+
name: 'stream-worker',
|
|
16140
|
+
bindings: {
|
|
16141
|
+
stream: {
|
|
16142
|
+
STREAM: true
|
|
16143
|
+
}
|
|
16144
|
+
}
|
|
16145
|
+
})
|
|
16146
|
+
```
|
|
16147
|
+
|
|
16148
|
+
###### File — .devflare/wrangler.jsonc
|
|
16149
|
+
|
|
16150
|
+
```json
|
|
16151
|
+
{
|
|
16152
|
+
"stream": {
|
|
16153
|
+
"binding": "STREAM"
|
|
16154
|
+
}
|
|
16155
|
+
}
|
|
16156
|
+
```
|
|
16157
|
+
|
|
16158
|
+
#### What local runtime support covers
|
|
16159
|
+
|
|
16160
|
+
##### Key points
|
|
16161
|
+
|
|
16162
|
+
- Full local support through the native Miniflare Stream plugin (a local StreamObject backed by disk persistence) plus a deterministic pure mock for app-level tests
|
|
16163
|
+
- The default docs recipe uses `createTestContext()` or `createOfflineEnv()`.
|
|
16164
|
+
- Pure unit tests can use `createMockStreamBinding()` / `createMockEnv({ stream })` when the test only needs deterministic application behavior.
|
|
16165
|
+
|
|
16166
|
+
#### Compile, preview, and cleanup behavior
|
|
16167
|
+
|
|
16168
|
+
##### Key points
|
|
16169
|
+
|
|
16170
|
+
- Devflare emits Wrangler `stream` from the native config surface.
|
|
16171
|
+
- Preview and deployment lifecycle stay feature-specific; do not assume all Cloudflare products can be created, cloned, or cleaned up the same way.
|
|
16172
|
+
- Cloudflare owns real video upload, transcode, delivery, signed tokens, and billing; the local mock only models the binding shape.
|
|
16173
|
+
|
|
16174
|
+
#### Cloudflare docs vs the Devflare layer
|
|
16175
|
+
|
|
16176
|
+
Cloudflare Workers bindings docs is the platform reference. Use this internals page when you need to compare Cloudflare's product docs with Devflare config, generated env types, local support, and preview behavior for `bindings.stream`.
|
|
16177
|
+
|
|
16178
|
+
##### Highlights
|
|
16179
|
+
|
|
16180
|
+
- **Cloudflare Workers bindings docs** — Platform reference for the underlying binding contract on Cloudflare Workers. ([link](https://developers.cloudflare.com/workers/runtime-apis/bindings/))
|
|
16181
|
+
|
|
16182
|
+
##### Reference table
|
|
16183
|
+
|
|
16184
|
+
| Question | Cloudflare docs | This Devflare page |
|
|
16185
|
+
| --- | --- | --- |
|
|
16186
|
+
| Primary focus | Platform reference for the underlying binding contract on Cloudflare Workers. | How to author `bindings.stream`, what the runtime surface looks like, and how Stream fits a Devflare project. |
|
|
16187
|
+
| Testing and runtime lens | Cloudflare’s docs focus on the raw binding API, product semantics, and platform limits for the binding itself. | Full local support through the native Miniflare Stream plugin (a local StreamObject backed by disk persistence) plus a deterministic pure mock for app-level tests. Use the Devflare guidance when you need the honest local harness or the right remote gate instead of only the product API shape. |
|
|
16188
|
+
| When to open it | When you need the platform contract, limits, APIs, or account-level product details. | When you are wiring, testing, previewing, or reviewing the binding inside a Devflare app. |
|
|
16189
|
+
|
|
16190
|
+
---
|
|
16191
|
+
|
|
16192
|
+
### Test Stream the way Devflare expects it to run
|
|
16193
|
+
|
|
16194
|
+
> Test Stream by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default.
|
|
16195
|
+
|
|
16196
|
+
| Field | Value |
|
|
16197
|
+
| --- | --- |
|
|
16198
|
+
| Route | [`/docs/bindings/stream/testing`](/docs/bindings/stream/testing) |
|
|
16199
|
+
| Group | Bindings |
|
|
16200
|
+
| Navigation title | Testing Stream |
|
|
16201
|
+
| Eyebrow | Testing |
|
|
16202
|
+
|
|
16203
|
+
The first test should prove application control flow. Escalate to Wrangler remote binding or deployed tests only when the Cloudflare-hosted behavior is the thing under test.
|
|
16204
|
+
|
|
16205
|
+
#### At a glance
|
|
16206
|
+
|
|
16207
|
+
| Fact | Value |
|
|
16208
|
+
| --- | --- |
|
|
16209
|
+
| Best for | video listing and per-video metadata paths where the Worker calls the Stream binding |
|
|
16210
|
+
| Default harness | `createTestContext()` or `createOfflineEnv()` |
|
|
16211
|
+
| Escalate when | The assertion depends on Cloudflare-hosted product behavior rather than the app calling the binding correctly |
|
|
16212
|
+
|
|
16213
|
+
#### Start with the default test loop
|
|
16214
|
+
|
|
16215
|
+
Keep the first test small. Name the binding, call the one method your route uses, and assert the behavior your app owns.
|
|
16216
|
+
|
|
16217
|
+
When Cloudflare owns the interesting behavior, mark that as a remote/deployed lane instead of building a local fake that claims too much.
|
|
16218
|
+
|
|
16219
|
+
##### Example — Pure Stream shape test
|
|
16220
|
+
|
|
16221
|
+
```ts
|
|
16222
|
+
import { expect, test } from 'bun:test'
|
|
16223
|
+
import { createMockStreamBinding } from 'devflare/test'
|
|
16224
|
+
|
|
16225
|
+
test('lists no videos by default', async () => {
|
|
16226
|
+
const stream = createMockStreamBinding()
|
|
16227
|
+
const videos = await stream.videos.list()
|
|
16228
|
+
|
|
16229
|
+
expect(videos).toEqual([])
|
|
16230
|
+
})
|
|
16231
|
+
```
|
|
16232
|
+
|
|
16233
|
+
#### The helper surface to remember
|
|
16234
|
+
|
|
16235
|
+
##### Key points
|
|
16236
|
+
|
|
16237
|
+
- Use `createTestContext()` or `createOfflineEnv()` for config-backed local worker tests.
|
|
16238
|
+
- Use `createMockStreamBinding()` / `createMockEnv({ stream })` for pure unit tests.
|
|
16239
|
+
- Use `shouldSkip` or an explicit integration lane when the test needs Cloudflare credentials or a local Docker/Podman engine.
|
|
16240
|
+
|
|
16241
|
+
#### When to move beyond the default harness
|
|
16242
|
+
|
|
16243
|
+
##### Key points
|
|
16244
|
+
|
|
16245
|
+
- Cloudflare owns real video upload, transcode, delivery, signed tokens, and billing; the local mock only models the binding shape.
|
|
16246
|
+
- Do not let a low-fidelity mock become product documentation. Keep mocks framed as application-flow tools.
|
|
16247
|
+
- If a test would mutate paid or remote Cloudflare state, gate it separately from ordinary unit tests.
|
|
16248
|
+
|
|
16249
|
+
> **Warning — Local tests should be honest**
|
|
16250
|
+
>
|
|
16251
|
+
> For Stream, passing locally means the Devflare contract and app flow are correct. It does not automatically prove every hosted Cloudflare behavior.
|
|
16252
|
+
|
|
16253
|
+
---
|
|
16254
|
+
|
|
16255
|
+
### Use Stream in a real application path
|
|
16256
|
+
|
|
16257
|
+
> A compact Stream recipe with config and worker usage in one application path.
|
|
16258
|
+
|
|
16259
|
+
| Field | Value |
|
|
16260
|
+
| --- | --- |
|
|
16261
|
+
| Route | [`/docs/bindings/stream/example`](/docs/bindings/stream/example) |
|
|
16262
|
+
| Group | Bindings |
|
|
16263
|
+
| Navigation title | Stream example |
|
|
16264
|
+
| Eyebrow | Application example |
|
|
16265
|
+
|
|
16266
|
+
Use this as the copyable starter before threading the feature into a larger application.
|
|
16267
|
+
|
|
16268
|
+
#### At a glance
|
|
16269
|
+
|
|
16270
|
+
| Fact | Value |
|
|
16271
|
+
| --- | --- |
|
|
16272
|
+
| Config focus | bindings.stream |
|
|
16273
|
+
| Runtime shape | `StreamBinding` |
|
|
16274
|
+
| Best use | video listing and per-video metadata paths where the Worker calls the Stream binding |
|
|
16275
|
+
|
|
16276
|
+
#### Start by wiring the binding clearly in config
|
|
16277
|
+
|
|
16278
|
+
##### Example — Smallest Stream config
|
|
16279
|
+
|
|
16280
|
+
```ts
|
|
16281
|
+
import { defineConfig } from 'devflare/config'
|
|
16282
|
+
|
|
16283
|
+
export default defineConfig({
|
|
16284
|
+
name: 'stream-worker',
|
|
16285
|
+
bindings: {
|
|
16286
|
+
stream: {
|
|
16287
|
+
STREAM: true
|
|
16288
|
+
}
|
|
16289
|
+
}
|
|
16290
|
+
})
|
|
16291
|
+
```
|
|
16292
|
+
|
|
16293
|
+
#### Build the application flow around the binding
|
|
16294
|
+
|
|
16295
|
+
Treat this as the app-level Stream path: the route, event handler, or service module receives a real request and uses the binding to do useful work.
|
|
16296
|
+
|
|
16297
|
+
Keep product limits, remote ownership, and fallback behavior visible in the code around the binding instead of hiding everything behind a vague utility too early.
|
|
16298
|
+
|
|
16299
|
+
##### Key points
|
|
16300
|
+
|
|
16301
|
+
- Keep the first example short enough to paste into a new Worker.
|
|
16302
|
+
- Cloudflare owns real video upload, transcode, delivery, signed tokens, and billing; the local mock only models the binding shape.
|
|
16303
|
+
|
|
16304
|
+
##### Example — List Stream videos
|
|
16305
|
+
|
|
16306
|
+
```ts
|
|
16307
|
+
import { env } from 'devflare/runtime'
|
|
16308
|
+
|
|
16309
|
+
export async function fetch(): Promise<Response> {
|
|
16310
|
+
const videos = await env.STREAM.videos.list()
|
|
16311
|
+
|
|
16312
|
+
return Response.json({ count: videos.length })
|
|
16313
|
+
}
|
|
16314
|
+
```
|
|
16315
|
+
|
|
16316
|
+
#### Keep production boundaries visible
|
|
16317
|
+
|
|
16318
|
+
##### Key points
|
|
16319
|
+
|
|
16320
|
+
- Config focus: bindings.stream.
|
|
16321
|
+
- Runtime shape: `StreamBinding`.
|
|
16322
|
+
- Best use: video listing and per-video metadata paths where the Worker calls the Stream binding.
|
|
16323
|
+
|
|
16324
|
+
> **Important — Thread this into the next recipe**
|
|
16325
|
+
>
|
|
16326
|
+
> Once this smallest path works, add routing, generated types, and feature-specific abstraction in that order.
|
|
16327
|
+
|
|
16328
|
+
---
|
|
16329
|
+
|
|
16330
|
+
### Use VPC Services in a Worker
|
|
16331
|
+
|
|
16332
|
+
> Add the VPC Services config, call a VPC service `Fetcher` from worker code, and start with the local test path Devflare supports.
|
|
16333
|
+
|
|
16334
|
+
| Field | Value |
|
|
16335
|
+
| --- | --- |
|
|
16336
|
+
| Route | [`/docs/bindings/vpc-services`](/docs/bindings/vpc-services) |
|
|
16337
|
+
| Group | Bindings |
|
|
16338
|
+
| Navigation title | VPC Services |
|
|
16339
|
+
| Eyebrow | Binding reference |
|
|
16340
|
+
|
|
16341
|
+
Start with the config, wire the binding into worker code, then use the support section to decide whether local tests or Cloudflare-backed tests fit.
|
|
16342
|
+
|
|
16343
|
+
#### At a glance
|
|
16344
|
+
|
|
16345
|
+
| Fact | Value |
|
|
16346
|
+
| --- | --- |
|
|
16347
|
+
| Config key | `bindings.vpcServices` |
|
|
16348
|
+
| Authoring shape | `Record<string, { serviceId; remote? }>` |
|
|
16349
|
+
| Best for | reaching a private upstream service over a Cloudflare VPC connectivity service |
|
|
16350
|
+
|
|
16351
|
+
#### Add the binding to config
|
|
16352
|
+
|
|
16353
|
+
Add `bindings.vpcServices` to `devflare.config.ts`, then use the generated env binding from Worker code.
|
|
16354
|
+
|
|
16355
|
+
Keep the first version close to the route or handler that needs it; move to a helper only after the shape is obvious.
|
|
16356
|
+
|
|
16357
|
+
##### Example — Smallest VPC service config
|
|
16358
|
+
|
|
16359
|
+
```ts
|
|
16360
|
+
import { defineConfig } from 'devflare/config'
|
|
16361
|
+
|
|
16362
|
+
export default defineConfig({
|
|
16363
|
+
name: 'vpc-service-worker',
|
|
16364
|
+
bindings: {
|
|
16365
|
+
vpcServices: {
|
|
16366
|
+
DB: {
|
|
16367
|
+
serviceId: 'service-uuid'
|
|
16368
|
+
}
|
|
16369
|
+
}
|
|
16370
|
+
}
|
|
16371
|
+
})
|
|
16372
|
+
```
|
|
16373
|
+
|
|
16374
|
+
#### Use the binding from application code
|
|
16375
|
+
|
|
16376
|
+
After Devflare generates the worker env, import `env` from `devflare/runtime` and keep the first VPC Services path close to the route, handler, or service method that needs it.
|
|
16377
|
+
|
|
16378
|
+
Keep this first path small enough that the config, env binding, and user-visible behavior are easy to review together.
|
|
16379
|
+
|
|
16380
|
+
##### Example — Call a private service over VPC
|
|
16381
|
+
|
|
16382
|
+
```ts
|
|
16383
|
+
import { env } from 'devflare/runtime'
|
|
16384
|
+
|
|
16385
|
+
export async function fetch(): Promise<Response> {
|
|
16386
|
+
return env.DB.fetch('https://internal.service/health')
|
|
16387
|
+
}
|
|
16388
|
+
```
|
|
16389
|
+
|
|
16390
|
+
#### Local and Remote Support
|
|
16391
|
+
|
|
16392
|
+
Devflare supports the config, generated env shape, docs, and local application-flow work, but full fidelity requires Cloudflare remote infrastructure. Use local shims or fixtures for code your app owns, then connect to Cloudflare when the product behavior is the assertion.
|
|
16393
|
+
|
|
16394
|
+
Remote boundary: Miniflare wires VPC services only as a remote proxy client, so there is no offline simulation. Keep local coverage focused on deterministic application flow through fixtures, mocks, shims, or Miniflare-backed wiring instead of pretending to reproduce Cloudflare-hosted product behavior.
|
|
16395
|
+
|
|
16396
|
+
Use Cloudflare when the assertion depends on cloudflare-hosted product behavior rather than the app calling the binding correctly. This is the lane for full VPC Services product fidelity, remote state, lifecycle behavior, and platform-specific limits.
|
|
16397
|
+
|
|
16398
|
+
#### When this binding fits best
|
|
16399
|
+
|
|
16400
|
+
##### Key points
|
|
16401
|
+
|
|
16402
|
+
- Use VPC Services when reaching a private upstream service over a cloudflare vpc connectivity service.
|
|
16403
|
+
- Keep binding names stable and uppercase in examples so generated Env declarations remain predictable.
|
|
16404
|
+
- Prefer Devflare native config while it covers the feature; use `wrangler.passthrough` only for unsupported Wrangler-only fields.
|
|
16405
|
+
|
|
16406
|
+
#### Testing path
|
|
16407
|
+
|
|
16408
|
+
##### Key points
|
|
16409
|
+
|
|
16410
|
+
- Start with a deployed or remote-mode test against the real VPC service for config-backed local worker tests.
|
|
16411
|
+
- Use a custom fake binding injected through `createMockEnv()` for small unit tests that only need deterministic application behavior.
|
|
16412
|
+
- Use Cloudflare-backed tests when the assertion depends on hosted platform behavior, account state, limits, billing, or production routing.
|
|
16413
|
+
|
|
16414
|
+
#### Open the next page when you need it
|
|
16415
|
+
|
|
16416
|
+
##### Highlights
|
|
16417
|
+
|
|
16418
|
+
- **VPC Services internals** — Check emitted Wrangler `vpc_services`, preview behavior, and Cloudflare-specific details. ([link](/docs/bindings/vpc-services/internals))
|
|
16419
|
+
- **Testing VPC Services** — Pick the a deployed or remote-mode test against the real VPC service path first, then move to remote checks only when the test needs them. ([link](/docs/bindings/vpc-services/testing))
|
|
16420
|
+
- **VPC Services example** — Copy a fuller application path when the quick example is too small. ([link](/docs/bindings/vpc-services/example))
|
|
16421
|
+
|
|
16422
|
+
---
|
|
16423
|
+
|
|
16424
|
+
### How Devflare wires VPC Services from config to runtime
|
|
16425
|
+
|
|
16426
|
+
> VPC Services compiles from `bindings.vpcServices` to Wrangler `vpc_services`, with local/test behavior called out explicitly.
|
|
16427
|
+
|
|
16428
|
+
| Field | Value |
|
|
16429
|
+
| --- | --- |
|
|
16430
|
+
| Route | [`/docs/bindings/vpc-services/internals`](/docs/bindings/vpc-services/internals) |
|
|
16431
|
+
| Group | Bindings |
|
|
16432
|
+
| Navigation title | VPC Services internals |
|
|
16433
|
+
| Eyebrow | Under the hood |
|
|
16434
|
+
|
|
16435
|
+
Use this page when you need emitted config, preview behavior, or Cloudflare-specific limits. The overview and example pages stay focused on everyday app code.
|
|
16436
|
+
|
|
16437
|
+
#### At a glance
|
|
16438
|
+
|
|
16439
|
+
| Fact | Value |
|
|
16440
|
+
| --- | --- |
|
|
16441
|
+
| Normalization | Devflare normalizes `bindings.vpcServices` before emitting Wrangler `vpc_services` |
|
|
16442
|
+
| Compile target | Wrangler `vpc_services` |
|
|
16443
|
+
| Preview note | Cloudflare owns the VPC connectivity service and the private network path; there is no local simulation because Miniflare only proxies to the remote service. |
|
|
16444
|
+
|
|
16445
|
+
#### How authored config becomes Wrangler config
|
|
16446
|
+
|
|
16447
|
+
The authored config stays camelCase and project-oriented. The compiler translates that into the Wrangler keys Cloudflare expects.
|
|
16448
|
+
|
|
16449
|
+
The emitted output is shown here so the usage pages do not have to explain compiler details.
|
|
16450
|
+
|
|
16451
|
+
##### Example — VPC Services config and emitted Wrangler output
|
|
16452
|
+
|
|
16453
|
+
Use this when you need to check how the Devflare config becomes Wrangler-compatible config.
|
|
16454
|
+
|
|
16455
|
+
###### File — devflare.config.ts
|
|
16456
|
+
|
|
16457
|
+
```ts
|
|
16458
|
+
import { defineConfig } from 'devflare/config'
|
|
16459
|
+
|
|
16460
|
+
export default defineConfig({
|
|
16461
|
+
name: 'vpc-service-worker',
|
|
16462
|
+
bindings: {
|
|
16463
|
+
vpcServices: {
|
|
16464
|
+
DB: {
|
|
16465
|
+
serviceId: 'service-uuid'
|
|
16466
|
+
}
|
|
16467
|
+
}
|
|
16468
|
+
}
|
|
16469
|
+
})
|
|
16470
|
+
```
|
|
16471
|
+
|
|
16472
|
+
###### File — .devflare/wrangler.jsonc
|
|
16473
|
+
|
|
16474
|
+
```json
|
|
16475
|
+
{
|
|
16476
|
+
"vpc_services": [
|
|
16477
|
+
{ "binding": "DB", "service_id": "service-uuid" }
|
|
16478
|
+
]
|
|
16479
|
+
}
|
|
16480
|
+
```
|
|
16481
|
+
|
|
16482
|
+
#### What local runtime support covers
|
|
16483
|
+
|
|
16484
|
+
##### Key points
|
|
16485
|
+
|
|
16486
|
+
- Remote boundary: Miniflare wires VPC services only as a remote proxy client, so there is no offline simulation
|
|
16487
|
+
- The default docs recipe uses a deployed or remote-mode test against the real VPC service.
|
|
16488
|
+
- Pure unit tests can use a custom fake binding injected through `createMockEnv()` when the test only needs deterministic application behavior.
|
|
16489
|
+
|
|
16490
|
+
#### Compile, preview, and cleanup behavior
|
|
16491
|
+
|
|
16492
|
+
##### Key points
|
|
16493
|
+
|
|
16494
|
+
- Devflare emits Wrangler `vpc_services` from the native config surface.
|
|
16495
|
+
- Preview and deployment lifecycle stay feature-specific; do not assume all Cloudflare products can be created, cloned, or cleaned up the same way.
|
|
16496
|
+
- Cloudflare owns the VPC connectivity service and the private network path; there is no local simulation because Miniflare only proxies to the remote service.
|
|
16497
|
+
|
|
16498
|
+
#### Cloudflare docs vs the Devflare layer
|
|
16499
|
+
|
|
16500
|
+
Cloudflare Workers bindings docs is the platform reference. Use this internals page when you need to compare Cloudflare's product docs with Devflare config, generated env types, local support, and preview behavior for `bindings.vpcServices`.
|
|
16501
|
+
|
|
16502
|
+
##### Highlights
|
|
16503
|
+
|
|
16504
|
+
- **Cloudflare Workers bindings docs** — Platform reference for the underlying binding contract on Cloudflare Workers. ([link](https://developers.cloudflare.com/workers/runtime-apis/bindings/))
|
|
16505
|
+
|
|
16506
|
+
##### Reference table
|
|
16507
|
+
|
|
16508
|
+
| Question | Cloudflare docs | This Devflare page |
|
|
16509
|
+
| --- | --- | --- |
|
|
16510
|
+
| Primary focus | Platform reference for the underlying binding contract on Cloudflare Workers. | How to author `bindings.vpcServices`, what the runtime surface looks like, and how VPC Services fits a Devflare project. |
|
|
16511
|
+
| Testing and runtime lens | Cloudflare’s docs focus on the raw binding API, product semantics, and platform limits for the binding itself. | Remote boundary: Miniflare wires VPC services only as a remote proxy client, so there is no offline simulation. Use the Devflare guidance when you need the honest local harness or the right remote gate instead of only the product API shape. |
|
|
16512
|
+
| When to open it | When you need the platform contract, limits, APIs, or account-level product details. | When you are wiring, testing, previewing, or reviewing the binding inside a Devflare app. |
|
|
16513
|
+
|
|
16514
|
+
---
|
|
16515
|
+
|
|
16516
|
+
### Test VPC Services the way Devflare expects it to run
|
|
16517
|
+
|
|
16518
|
+
> Test VPC Services by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default.
|
|
16519
|
+
|
|
16520
|
+
| Field | Value |
|
|
16521
|
+
| --- | --- |
|
|
16522
|
+
| Route | [`/docs/bindings/vpc-services/testing`](/docs/bindings/vpc-services/testing) |
|
|
16523
|
+
| Group | Bindings |
|
|
16524
|
+
| Navigation title | Testing VPC Services |
|
|
16525
|
+
| Eyebrow | Testing |
|
|
16526
|
+
|
|
16527
|
+
The first test should prove application control flow. Escalate to Wrangler remote binding or deployed tests only when the Cloudflare-hosted behavior is the thing under test.
|
|
16528
|
+
|
|
16529
|
+
#### At a glance
|
|
16530
|
+
|
|
16531
|
+
| Fact | Value |
|
|
16532
|
+
| --- | --- |
|
|
16533
|
+
| Best for | reaching a private upstream service over a Cloudflare VPC connectivity service |
|
|
16534
|
+
| Default harness | a deployed or remote-mode test against the real VPC service |
|
|
16535
|
+
| Escalate when | The assertion depends on Cloudflare-hosted product behavior rather than the app calling the binding correctly |
|
|
16536
|
+
|
|
16537
|
+
#### Start with the default test loop
|
|
16538
|
+
|
|
16539
|
+
Keep the first test small. Name the binding, call the one method your route uses, and assert the behavior your app owns.
|
|
16540
|
+
|
|
16541
|
+
When Cloudflare owns the interesting behavior, mark that as a remote/deployed lane instead of building a local fake that claims too much.
|
|
16542
|
+
|
|
16543
|
+
##### Example — Test the app flow with a custom VPC fake
|
|
16544
|
+
|
|
16545
|
+
```ts
|
|
16546
|
+
import { expect, test } from 'bun:test'
|
|
16547
|
+
import { createMockEnv } from 'devflare/test'
|
|
16548
|
+
|
|
16549
|
+
test('reaches the private service over VPC', async () => {
|
|
16550
|
+
const env = createMockEnv({
|
|
16551
|
+
custom: { DB: { fetch: async () => new Response('ok') } }
|
|
16552
|
+
}) as { DB: Fetcher }
|
|
16553
|
+
|
|
16554
|
+
const response = await env.DB.fetch('https://internal.service/health')
|
|
16555
|
+
|
|
16556
|
+
expect(await response.text()).toBe('ok')
|
|
16557
|
+
})
|
|
16558
|
+
```
|
|
16559
|
+
|
|
16560
|
+
#### The helper surface to remember
|
|
16561
|
+
|
|
16562
|
+
##### Key points
|
|
16563
|
+
|
|
16564
|
+
- Use a deployed or remote-mode test against the real VPC service for config-backed local worker tests.
|
|
16565
|
+
- Use a custom fake binding injected through `createMockEnv()` for pure unit tests.
|
|
16566
|
+
- Use `shouldSkip` or an explicit integration lane when the test needs Cloudflare credentials or a local Docker/Podman engine.
|
|
16567
|
+
|
|
16568
|
+
#### When to move beyond the default harness
|
|
16569
|
+
|
|
16570
|
+
##### Key points
|
|
16571
|
+
|
|
16572
|
+
- Cloudflare owns the VPC connectivity service and the private network path; there is no local simulation because Miniflare only proxies to the remote service.
|
|
16573
|
+
- Do not let a low-fidelity mock become product documentation. Keep mocks framed as application-flow tools.
|
|
16574
|
+
- If a test would mutate paid or remote Cloudflare state, gate it separately from ordinary unit tests.
|
|
16575
|
+
|
|
16576
|
+
> **Warning — Local tests should be honest**
|
|
16577
|
+
>
|
|
16578
|
+
> For VPC Services, passing locally means the Devflare contract and app flow are correct. It does not automatically prove every hosted Cloudflare behavior.
|
|
16579
|
+
|
|
16580
|
+
---
|
|
16581
|
+
|
|
16582
|
+
### Use VPC Services in a real application path
|
|
16583
|
+
|
|
16584
|
+
> A compact VPC Services recipe with config and worker usage in one application path.
|
|
16585
|
+
|
|
16586
|
+
| Field | Value |
|
|
16587
|
+
| --- | --- |
|
|
16588
|
+
| Route | [`/docs/bindings/vpc-services/example`](/docs/bindings/vpc-services/example) |
|
|
16589
|
+
| Group | Bindings |
|
|
16590
|
+
| Navigation title | VPC Services example |
|
|
16591
|
+
| Eyebrow | Application example |
|
|
16592
|
+
|
|
16593
|
+
Use this as the copyable starter before threading the feature into a larger application.
|
|
16594
|
+
|
|
16595
|
+
#### At a glance
|
|
16596
|
+
|
|
16597
|
+
| Fact | Value |
|
|
16598
|
+
| --- | --- |
|
|
16599
|
+
| Config focus | bindings.vpcServices |
|
|
16600
|
+
| Runtime shape | a VPC service `Fetcher` |
|
|
16601
|
+
| Best use | reaching a private upstream service over a Cloudflare VPC connectivity service |
|
|
16602
|
+
|
|
16603
|
+
#### Start by wiring the binding clearly in config
|
|
16604
|
+
|
|
16605
|
+
##### Example — Smallest VPC service config
|
|
16606
|
+
|
|
16607
|
+
```ts
|
|
16608
|
+
import { defineConfig } from 'devflare/config'
|
|
16609
|
+
|
|
16610
|
+
export default defineConfig({
|
|
16611
|
+
name: 'vpc-service-worker',
|
|
16612
|
+
bindings: {
|
|
16613
|
+
vpcServices: {
|
|
16614
|
+
DB: {
|
|
16615
|
+
serviceId: 'service-uuid'
|
|
16616
|
+
}
|
|
16617
|
+
}
|
|
16618
|
+
}
|
|
16619
|
+
})
|
|
16620
|
+
```
|
|
16621
|
+
|
|
16622
|
+
#### Build the application flow around the binding
|
|
16623
|
+
|
|
16624
|
+
Treat this as the app-level VPC Services path: the route, event handler, or service module receives a real request and uses the binding to do useful work.
|
|
16625
|
+
|
|
16626
|
+
Keep product limits, remote ownership, and fallback behavior visible in the code around the binding instead of hiding everything behind a vague utility too early.
|
|
16627
|
+
|
|
16628
|
+
##### Key points
|
|
16629
|
+
|
|
16630
|
+
- Keep the first example short enough to paste into a new Worker.
|
|
16631
|
+
- Cloudflare owns the VPC connectivity service and the private network path; there is no local simulation because Miniflare only proxies to the remote service.
|
|
16632
|
+
|
|
16633
|
+
##### Example — Call a private service over VPC
|
|
16634
|
+
|
|
16635
|
+
```ts
|
|
16636
|
+
import { env } from 'devflare/runtime'
|
|
16637
|
+
|
|
16638
|
+
export async function fetch(): Promise<Response> {
|
|
16639
|
+
return env.DB.fetch('https://internal.service/health')
|
|
16640
|
+
}
|
|
16641
|
+
```
|
|
16642
|
+
|
|
16643
|
+
#### Keep production boundaries visible
|
|
16644
|
+
|
|
16645
|
+
##### Key points
|
|
16646
|
+
|
|
16647
|
+
- Config focus: bindings.vpcServices.
|
|
16648
|
+
- Runtime shape: a VPC service `Fetcher`.
|
|
16649
|
+
- Best use: reaching a private upstream service over a Cloudflare VPC connectivity service.
|
|
16650
|
+
|
|
16651
|
+
> **Important — Thread this into the next recipe**
|
|
16652
|
+
>
|
|
16653
|
+
> Once this smallest path works, add routing, generated types, and feature-specific abstraction in that order.
|
|
16654
|
+
|
|
16655
|
+
---
|
|
16656
|
+
|
|
16657
|
+
### Use VPC Networks in a Worker
|
|
16658
|
+
|
|
16659
|
+
> Add the VPC Networks config, call a VPC network `Fetcher` from worker code, and start with the local test path Devflare supports.
|
|
16660
|
+
|
|
16661
|
+
| Field | Value |
|
|
16662
|
+
| --- | --- |
|
|
16663
|
+
| Route | [`/docs/bindings/vpc-networks`](/docs/bindings/vpc-networks) |
|
|
16664
|
+
| Group | Bindings |
|
|
16665
|
+
| Navigation title | VPC Networks |
|
|
16666
|
+
| Eyebrow | Binding reference |
|
|
16667
|
+
|
|
16668
|
+
Start with the config, wire the binding into worker code, then use the support section to decide whether local tests or Cloudflare-backed tests fit.
|
|
16669
|
+
|
|
16670
|
+
#### At a glance
|
|
16671
|
+
|
|
16672
|
+
| Fact | Value |
|
|
16673
|
+
| --- | --- |
|
|
16674
|
+
| Config key | `bindings.vpcNetworks` |
|
|
16675
|
+
| Authoring shape | `Record<string, { tunnelId } \| { networkId }>` |
|
|
16676
|
+
| Best for | routing Worker traffic through a Cloudflare Tunnel or a private network ID |
|
|
16677
|
+
|
|
16678
|
+
#### Add the binding to config
|
|
16679
|
+
|
|
16680
|
+
Add `bindings.vpcNetworks` to `devflare.config.ts`, then use the generated env binding from Worker code.
|
|
16681
|
+
|
|
16682
|
+
Keep the first version close to the route or handler that needs it; move to a helper only after the shape is obvious.
|
|
16683
|
+
|
|
16684
|
+
##### Example — Smallest VPC network config
|
|
16685
|
+
|
|
16686
|
+
```ts
|
|
16687
|
+
import { defineConfig } from 'devflare/config'
|
|
16688
|
+
|
|
16689
|
+
export default defineConfig({
|
|
16690
|
+
name: 'vpc-network-worker',
|
|
16691
|
+
bindings: {
|
|
16692
|
+
vpcNetworks: {
|
|
16693
|
+
NET: {
|
|
16694
|
+
tunnelId: 'tunnel-uuid'
|
|
16695
|
+
}
|
|
16696
|
+
}
|
|
16697
|
+
}
|
|
16698
|
+
})
|
|
16699
|
+
```
|
|
16700
|
+
|
|
16701
|
+
#### Use the binding from application code
|
|
16702
|
+
|
|
16703
|
+
After Devflare generates the worker env, import `env` from `devflare/runtime` and keep the first VPC Networks path close to the route, handler, or service method that needs it.
|
|
16704
|
+
|
|
16705
|
+
Keep this first path small enough that the config, env binding, and user-visible behavior are easy to review together.
|
|
16706
|
+
|
|
16707
|
+
##### Example — Route a request through the VPC network
|
|
16708
|
+
|
|
16709
|
+
```ts
|
|
16710
|
+
import { env } from 'devflare/runtime'
|
|
16711
|
+
|
|
16712
|
+
export async function fetch(): Promise<Response> {
|
|
16713
|
+
return env.NET.fetch('https://10.0.0.10/status')
|
|
16714
|
+
}
|
|
16715
|
+
```
|
|
16716
|
+
|
|
16717
|
+
#### Local and Remote Support
|
|
16718
|
+
|
|
16719
|
+
Devflare supports the config, generated env shape, docs, and local application-flow work, but full fidelity requires Cloudflare remote infrastructure. Use local shims or fixtures for code your app owns, then connect to Cloudflare when the product behavior is the assertion.
|
|
16720
|
+
|
|
16721
|
+
Remote boundary: Miniflare wires VPC networks only as a remote proxy client, so there is no offline simulation. Keep local coverage focused on deterministic application flow through fixtures, mocks, shims, or Miniflare-backed wiring instead of pretending to reproduce Cloudflare-hosted product behavior.
|
|
16722
|
+
|
|
16723
|
+
Use Cloudflare when the assertion depends on cloudflare-hosted product behavior rather than the app calling the binding correctly. This is the lane for full VPC Networks product fidelity, remote state, lifecycle behavior, and platform-specific limits.
|
|
16724
|
+
|
|
16725
|
+
#### When this binding fits best
|
|
16726
|
+
|
|
16727
|
+
##### Key points
|
|
16728
|
+
|
|
16729
|
+
- Use VPC Networks when routing worker traffic through a cloudflare tunnel or a private network id.
|
|
16730
|
+
- Keep binding names stable and uppercase in examples so generated Env declarations remain predictable.
|
|
16731
|
+
- Prefer Devflare native config while it covers the feature; use `wrangler.passthrough` only for unsupported Wrangler-only fields.
|
|
16732
|
+
|
|
16733
|
+
#### Testing path
|
|
16734
|
+
|
|
16735
|
+
##### Key points
|
|
16736
|
+
|
|
16737
|
+
- Start with a deployed or remote-mode test against the real VPC network for config-backed local worker tests.
|
|
16738
|
+
- Use a custom fake binding injected through `createMockEnv()` for small unit tests that only need deterministic application behavior.
|
|
16739
|
+
- Use Cloudflare-backed tests when the assertion depends on hosted platform behavior, account state, limits, billing, or production routing.
|
|
16740
|
+
|
|
16741
|
+
#### Open the next page when you need it
|
|
16742
|
+
|
|
16743
|
+
##### Highlights
|
|
16744
|
+
|
|
16745
|
+
- **VPC Networks internals** — Check emitted Wrangler `vpc_networks`, preview behavior, and Cloudflare-specific details. ([link](/docs/bindings/vpc-networks/internals))
|
|
16746
|
+
- **Testing VPC Networks** — Pick the a deployed or remote-mode test against the real VPC network path first, then move to remote checks only when the test needs them. ([link](/docs/bindings/vpc-networks/testing))
|
|
16747
|
+
- **VPC Networks example** — Copy a fuller application path when the quick example is too small. ([link](/docs/bindings/vpc-networks/example))
|
|
16748
|
+
|
|
16749
|
+
---
|
|
16750
|
+
|
|
16751
|
+
### How Devflare wires VPC Networks from config to runtime
|
|
16752
|
+
|
|
16753
|
+
> VPC Networks compiles from `bindings.vpcNetworks` to Wrangler `vpc_networks`, with local/test behavior called out explicitly.
|
|
16754
|
+
|
|
16755
|
+
| Field | Value |
|
|
16756
|
+
| --- | --- |
|
|
16757
|
+
| Route | [`/docs/bindings/vpc-networks/internals`](/docs/bindings/vpc-networks/internals) |
|
|
16758
|
+
| Group | Bindings |
|
|
16759
|
+
| Navigation title | VPC Networks internals |
|
|
16760
|
+
| Eyebrow | Under the hood |
|
|
16761
|
+
|
|
16762
|
+
Use this page when you need emitted config, preview behavior, or Cloudflare-specific limits. The overview and example pages stay focused on everyday app code.
|
|
16763
|
+
|
|
16764
|
+
#### At a glance
|
|
16765
|
+
|
|
16766
|
+
| Fact | Value |
|
|
16767
|
+
| --- | --- |
|
|
16768
|
+
| Normalization | Devflare normalizes `bindings.vpcNetworks` before emitting Wrangler `vpc_networks` |
|
|
16769
|
+
| Compile target | Wrangler `vpc_networks` |
|
|
16770
|
+
| Preview note | Cloudflare owns the Tunnel and private network path; there is no local simulation because Miniflare only proxies to the remote network. |
|
|
16771
|
+
|
|
16772
|
+
#### How authored config becomes Wrangler config
|
|
16773
|
+
|
|
16774
|
+
The authored config stays camelCase and project-oriented. The compiler translates that into the Wrangler keys Cloudflare expects.
|
|
16775
|
+
|
|
16776
|
+
The emitted output is shown here so the usage pages do not have to explain compiler details.
|
|
16777
|
+
|
|
16778
|
+
##### Example — VPC Networks config and emitted Wrangler output
|
|
16779
|
+
|
|
16780
|
+
Use this when you need to check how the Devflare config becomes Wrangler-compatible config.
|
|
16781
|
+
|
|
16782
|
+
###### File — devflare.config.ts
|
|
16783
|
+
|
|
16784
|
+
```ts
|
|
16785
|
+
import { defineConfig } from 'devflare/config'
|
|
16786
|
+
|
|
16787
|
+
export default defineConfig({
|
|
16788
|
+
name: 'vpc-network-worker',
|
|
16789
|
+
bindings: {
|
|
16790
|
+
vpcNetworks: {
|
|
16791
|
+
NET: {
|
|
16792
|
+
tunnelId: 'tunnel-uuid'
|
|
16793
|
+
}
|
|
16794
|
+
}
|
|
16795
|
+
}
|
|
16796
|
+
})
|
|
16797
|
+
```
|
|
16798
|
+
|
|
16799
|
+
###### File — .devflare/wrangler.jsonc
|
|
16800
|
+
|
|
16801
|
+
```json
|
|
16802
|
+
{
|
|
16803
|
+
"vpc_networks": [
|
|
16804
|
+
{ "binding": "NET", "tunnel_id": "tunnel-uuid" }
|
|
16805
|
+
]
|
|
16806
|
+
}
|
|
16807
|
+
```
|
|
16808
|
+
|
|
16809
|
+
#### What local runtime support covers
|
|
16810
|
+
|
|
16811
|
+
##### Key points
|
|
16812
|
+
|
|
16813
|
+
- Remote boundary: Miniflare wires VPC networks only as a remote proxy client, so there is no offline simulation
|
|
16814
|
+
- The default docs recipe uses a deployed or remote-mode test against the real VPC network.
|
|
16815
|
+
- Pure unit tests can use a custom fake binding injected through `createMockEnv()` when the test only needs deterministic application behavior.
|
|
16816
|
+
|
|
16817
|
+
#### Compile, preview, and cleanup behavior
|
|
16818
|
+
|
|
16819
|
+
##### Key points
|
|
16820
|
+
|
|
16821
|
+
- Devflare emits Wrangler `vpc_networks` from the native config surface.
|
|
16822
|
+
- Preview and deployment lifecycle stay feature-specific; do not assume all Cloudflare products can be created, cloned, or cleaned up the same way.
|
|
16823
|
+
- Cloudflare owns the Tunnel and private network path; there is no local simulation because Miniflare only proxies to the remote network.
|
|
16824
|
+
|
|
16825
|
+
#### Cloudflare docs vs the Devflare layer
|
|
16826
|
+
|
|
16827
|
+
Cloudflare Workers bindings docs is the platform reference. Use this internals page when you need to compare Cloudflare's product docs with Devflare config, generated env types, local support, and preview behavior for `bindings.vpcNetworks`.
|
|
16828
|
+
|
|
16829
|
+
##### Highlights
|
|
16830
|
+
|
|
16831
|
+
- **Cloudflare Workers bindings docs** — Platform reference for the underlying binding contract on Cloudflare Workers. ([link](https://developers.cloudflare.com/workers/runtime-apis/bindings/))
|
|
16832
|
+
|
|
16833
|
+
##### Reference table
|
|
16834
|
+
|
|
16835
|
+
| Question | Cloudflare docs | This Devflare page |
|
|
16836
|
+
| --- | --- | --- |
|
|
16837
|
+
| Primary focus | Platform reference for the underlying binding contract on Cloudflare Workers. | How to author `bindings.vpcNetworks`, what the runtime surface looks like, and how VPC Networks fits a Devflare project. |
|
|
16838
|
+
| Testing and runtime lens | Cloudflare’s docs focus on the raw binding API, product semantics, and platform limits for the binding itself. | Remote boundary: Miniflare wires VPC networks only as a remote proxy client, so there is no offline simulation. Use the Devflare guidance when you need the honest local harness or the right remote gate instead of only the product API shape. |
|
|
16839
|
+
| When to open it | When you need the platform contract, limits, APIs, or account-level product details. | When you are wiring, testing, previewing, or reviewing the binding inside a Devflare app. |
|
|
16840
|
+
|
|
16841
|
+
---
|
|
16842
|
+
|
|
16843
|
+
### Test VPC Networks the way Devflare expects it to run
|
|
16844
|
+
|
|
16845
|
+
> Test VPC Networks by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default.
|
|
16846
|
+
|
|
16847
|
+
| Field | Value |
|
|
16848
|
+
| --- | --- |
|
|
16849
|
+
| Route | [`/docs/bindings/vpc-networks/testing`](/docs/bindings/vpc-networks/testing) |
|
|
16850
|
+
| Group | Bindings |
|
|
16851
|
+
| Navigation title | Testing VPC Networks |
|
|
16852
|
+
| Eyebrow | Testing |
|
|
16853
|
+
|
|
16854
|
+
The first test should prove application control flow. Escalate to Wrangler remote binding or deployed tests only when the Cloudflare-hosted behavior is the thing under test.
|
|
16855
|
+
|
|
16856
|
+
#### At a glance
|
|
16857
|
+
|
|
16858
|
+
| Fact | Value |
|
|
16859
|
+
| --- | --- |
|
|
16860
|
+
| Best for | routing Worker traffic through a Cloudflare Tunnel or a private network ID |
|
|
16861
|
+
| Default harness | a deployed or remote-mode test against the real VPC network |
|
|
16862
|
+
| Escalate when | The assertion depends on Cloudflare-hosted product behavior rather than the app calling the binding correctly |
|
|
16863
|
+
|
|
16864
|
+
#### Start with the default test loop
|
|
16865
|
+
|
|
16866
|
+
Keep the first test small. Name the binding, call the one method your route uses, and assert the behavior your app owns.
|
|
16867
|
+
|
|
16868
|
+
When Cloudflare owns the interesting behavior, mark that as a remote/deployed lane instead of building a local fake that claims too much.
|
|
16869
|
+
|
|
16870
|
+
##### Example — Test the app flow with a custom VPC network fake
|
|
16871
|
+
|
|
16872
|
+
```ts
|
|
16873
|
+
import { expect, test } from 'bun:test'
|
|
16874
|
+
import { createMockEnv } from 'devflare/test'
|
|
16875
|
+
|
|
16876
|
+
test('routes a request through the VPC network', async () => {
|
|
16877
|
+
const env = createMockEnv({
|
|
16878
|
+
custom: { NET: { fetch: async () => new Response('ok') } }
|
|
16879
|
+
}) as { NET: Fetcher }
|
|
16880
|
+
|
|
16881
|
+
const response = await env.NET.fetch('https://10.0.0.10/status')
|
|
16882
|
+
|
|
16883
|
+
expect(await response.text()).toBe('ok')
|
|
16884
|
+
})
|
|
16885
|
+
```
|
|
16886
|
+
|
|
16887
|
+
#### The helper surface to remember
|
|
16888
|
+
|
|
16889
|
+
##### Key points
|
|
16890
|
+
|
|
16891
|
+
- Use a deployed or remote-mode test against the real VPC network for config-backed local worker tests.
|
|
16892
|
+
- Use a custom fake binding injected through `createMockEnv()` for pure unit tests.
|
|
16893
|
+
- Use `shouldSkip` or an explicit integration lane when the test needs Cloudflare credentials or a local Docker/Podman engine.
|
|
16894
|
+
|
|
16895
|
+
#### When to move beyond the default harness
|
|
16896
|
+
|
|
16897
|
+
##### Key points
|
|
16898
|
+
|
|
16899
|
+
- Cloudflare owns the Tunnel and private network path; there is no local simulation because Miniflare only proxies to the remote network.
|
|
16900
|
+
- Do not let a low-fidelity mock become product documentation. Keep mocks framed as application-flow tools.
|
|
16901
|
+
- If a test would mutate paid or remote Cloudflare state, gate it separately from ordinary unit tests.
|
|
16902
|
+
|
|
16903
|
+
> **Warning — Local tests should be honest**
|
|
16904
|
+
>
|
|
16905
|
+
> For VPC Networks, passing locally means the Devflare contract and app flow are correct. It does not automatically prove every hosted Cloudflare behavior.
|
|
16906
|
+
|
|
16907
|
+
---
|
|
16908
|
+
|
|
16909
|
+
### Use VPC Networks in a real application path
|
|
16910
|
+
|
|
16911
|
+
> A compact VPC Networks recipe with config and worker usage in one application path.
|
|
16912
|
+
|
|
16913
|
+
| Field | Value |
|
|
16914
|
+
| --- | --- |
|
|
16915
|
+
| Route | [`/docs/bindings/vpc-networks/example`](/docs/bindings/vpc-networks/example) |
|
|
16916
|
+
| Group | Bindings |
|
|
16917
|
+
| Navigation title | VPC Networks example |
|
|
16918
|
+
| Eyebrow | Application example |
|
|
16919
|
+
|
|
16920
|
+
Use this as the copyable starter before threading the feature into a larger application.
|
|
16921
|
+
|
|
16922
|
+
#### At a glance
|
|
16923
|
+
|
|
16924
|
+
| Fact | Value |
|
|
16925
|
+
| --- | --- |
|
|
16926
|
+
| Config focus | bindings.vpcNetworks |
|
|
16927
|
+
| Runtime shape | a VPC network `Fetcher` |
|
|
16928
|
+
| Best use | routing Worker traffic through a Cloudflare Tunnel or a private network ID |
|
|
16929
|
+
|
|
16930
|
+
#### Start by wiring the binding clearly in config
|
|
16931
|
+
|
|
16932
|
+
##### Example — Smallest VPC network config
|
|
16933
|
+
|
|
16934
|
+
```ts
|
|
16935
|
+
import { defineConfig } from 'devflare/config'
|
|
16936
|
+
|
|
16937
|
+
export default defineConfig({
|
|
16938
|
+
name: 'vpc-network-worker',
|
|
16939
|
+
bindings: {
|
|
16940
|
+
vpcNetworks: {
|
|
16941
|
+
NET: {
|
|
16942
|
+
tunnelId: 'tunnel-uuid'
|
|
16943
|
+
}
|
|
16944
|
+
}
|
|
16945
|
+
}
|
|
16946
|
+
})
|
|
16947
|
+
```
|
|
16948
|
+
|
|
16949
|
+
#### Build the application flow around the binding
|
|
16950
|
+
|
|
16951
|
+
Treat this as the app-level VPC Networks path: the route, event handler, or service module receives a real request and uses the binding to do useful work.
|
|
16952
|
+
|
|
16953
|
+
Keep product limits, remote ownership, and fallback behavior visible in the code around the binding instead of hiding everything behind a vague utility too early.
|
|
16954
|
+
|
|
16955
|
+
##### Key points
|
|
16956
|
+
|
|
16957
|
+
- Keep the first example short enough to paste into a new Worker.
|
|
16958
|
+
- Cloudflare owns the Tunnel and private network path; there is no local simulation because Miniflare only proxies to the remote network.
|
|
16959
|
+
|
|
16960
|
+
##### Example — Route a request through the VPC network
|
|
16961
|
+
|
|
16962
|
+
```ts
|
|
16963
|
+
import { env } from 'devflare/runtime'
|
|
16964
|
+
|
|
16965
|
+
export async function fetch(): Promise<Response> {
|
|
16966
|
+
return env.NET.fetch('https://10.0.0.10/status')
|
|
16967
|
+
}
|
|
16968
|
+
```
|
|
16969
|
+
|
|
16970
|
+
#### Keep production boundaries visible
|
|
16971
|
+
|
|
16972
|
+
##### Key points
|
|
16973
|
+
|
|
16974
|
+
- Config focus: bindings.vpcNetworks.
|
|
16975
|
+
- Runtime shape: a VPC network `Fetcher`.
|
|
16976
|
+
- Best use: routing Worker traffic through a Cloudflare Tunnel or a private network ID.
|
|
16977
|
+
|
|
16978
|
+
> **Important — Thread this into the next recipe**
|
|
16979
|
+
>
|
|
16980
|
+
> Once this smallest path works, add routing, generated types, and feature-specific abstraction in that order.
|
|
16981
|
+
|
|
16982
|
+
---
|
|
16983
|
+
|
|
16984
|
+
### Use Flagship in a Worker
|
|
16985
|
+
|
|
16986
|
+
> Add the Flagship config, call `Flagship` from worker code, and start with the local test path Devflare supports.
|
|
16987
|
+
|
|
16988
|
+
| Field | Value |
|
|
16989
|
+
| --- | --- |
|
|
16990
|
+
| Route | [`/docs/bindings/flagship`](/docs/bindings/flagship) |
|
|
16991
|
+
| Group | Bindings |
|
|
16992
|
+
| Navigation title | Flagship |
|
|
16993
|
+
| Eyebrow | Binding reference |
|
|
16994
|
+
|
|
16995
|
+
Start with the config, wire the binding into worker code, then use the support section to decide whether local tests or Cloudflare-backed tests fit.
|
|
16996
|
+
|
|
16997
|
+
#### At a glance
|
|
16998
|
+
|
|
16999
|
+
| Fact | Value |
|
|
17000
|
+
| --- | --- |
|
|
17001
|
+
| Config key | `bindings.flagship` |
|
|
17002
|
+
| Authoring shape | `Record<string, { appId; remote? }>` |
|
|
17003
|
+
| Best for | application paths where the Worker reads feature flags from the Flagship binding |
|
|
17004
|
+
|
|
17005
|
+
#### Add the binding to config
|
|
17006
|
+
|
|
17007
|
+
Add `bindings.flagship` to `devflare.config.ts`, then use the generated env binding from Worker code.
|
|
17008
|
+
|
|
17009
|
+
Keep the first version close to the route or handler that needs it; move to a helper only after the shape is obvious.
|
|
17010
|
+
|
|
17011
|
+
##### Example — Smallest Flagship config
|
|
17012
|
+
|
|
17013
|
+
```ts
|
|
17014
|
+
import { defineConfig } from 'devflare/config'
|
|
17015
|
+
|
|
17016
|
+
export default defineConfig({
|
|
17017
|
+
name: 'flagship-worker',
|
|
17018
|
+
bindings: {
|
|
17019
|
+
flagship: {
|
|
17020
|
+
FLAGS: {
|
|
17021
|
+
appId: 'app-id'
|
|
17022
|
+
}
|
|
17023
|
+
}
|
|
17024
|
+
}
|
|
17025
|
+
})
|
|
17026
|
+
```
|
|
17027
|
+
|
|
17028
|
+
#### Use the binding from application code
|
|
17029
|
+
|
|
17030
|
+
After Devflare generates the worker env, import `env` from `devflare/runtime` and keep the first Flagship path close to the route, handler, or service method that needs it.
|
|
17031
|
+
|
|
17032
|
+
Keep this first path small enough that the config, env binding, and user-visible behavior are easy to review together.
|
|
17033
|
+
|
|
17034
|
+
##### Example — Read a boolean flag
|
|
17035
|
+
|
|
17036
|
+
```ts
|
|
17037
|
+
import { env } from 'devflare/runtime'
|
|
17038
|
+
|
|
17039
|
+
export async function fetch(): Promise<Response> {
|
|
17040
|
+
const enabled = await env.FLAGS.getBooleanValue('new-checkout', false)
|
|
17041
|
+
|
|
17042
|
+
return Response.json({ enabled })
|
|
17043
|
+
}
|
|
17044
|
+
```
|
|
17045
|
+
|
|
17046
|
+
#### Local and Remote Support
|
|
17047
|
+
|
|
17048
|
+
Devflare has a real lane for Flagship, but the local contract is intentionally narrower than Cloudflare's hosted product. The docs call out the supported local path and the remote boundary separately.
|
|
17049
|
+
|
|
17050
|
+
Miniflare's Flagship plugin returns each call's default value locally and ignores the flag key (it does not evaluate flag rules), while Devflare's deterministic pure mock (createMockFlagshipBinding({ flags })) returns configured flag values, falling back to the default. Use the documented local lane only for the behavior Devflare explicitly models, and keep the narrower boundary visible in code review.
|
|
17051
|
+
|
|
17052
|
+
Use Cloudflare when the assertion depends on cloudflare-hosted product behavior rather than the app calling the binding correctly. This is the lane for full Flagship product fidelity, remote state, lifecycle behavior, and platform-specific limits.
|
|
17053
|
+
|
|
17054
|
+
#### When this binding fits best
|
|
17055
|
+
|
|
17056
|
+
##### Key points
|
|
17057
|
+
|
|
17058
|
+
- Use Flagship when application paths where the worker reads feature flags from the flagship binding.
|
|
17059
|
+
- Keep binding names stable and uppercase in examples so generated Env declarations remain predictable.
|
|
17060
|
+
- Prefer Devflare native config while it covers the feature; use `wrangler.passthrough` only for unsupported Wrangler-only fields.
|
|
17061
|
+
|
|
17062
|
+
#### Testing path
|
|
17063
|
+
|
|
17064
|
+
##### Key points
|
|
17065
|
+
|
|
17066
|
+
- Start with `createTestContext()` or `createOfflineEnv()` for config-backed local worker tests.
|
|
17067
|
+
- Use `createMockFlagshipBinding({ flags })` / `createMockEnv({ flagship })` for small unit tests that only need deterministic application behavior.
|
|
17068
|
+
- Use Cloudflare-backed tests when the assertion depends on hosted platform behavior, account state, limits, billing, or production routing.
|
|
17069
|
+
|
|
17070
|
+
#### Open the next page when you need it
|
|
17071
|
+
|
|
17072
|
+
##### Highlights
|
|
17073
|
+
|
|
17074
|
+
- **Flagship internals** — Check emitted Wrangler `flagship`, preview behavior, and Cloudflare-specific details. ([link](/docs/bindings/flagship/internals))
|
|
17075
|
+
- **Testing Flagship** — Pick the `createTestContext()` or `createOfflineEnv()` path first, then move to remote checks only when the test needs them. ([link](/docs/bindings/flagship/testing))
|
|
17076
|
+
- **Flagship example** — Copy a fuller application path when the quick example is too small. ([link](/docs/bindings/flagship/example))
|
|
17077
|
+
|
|
17078
|
+
---
|
|
17079
|
+
|
|
17080
|
+
### How Devflare wires Flagship from config to runtime
|
|
17081
|
+
|
|
17082
|
+
> Flagship compiles from `bindings.flagship` to Wrangler `flagship`, with local/test behavior called out explicitly.
|
|
17083
|
+
|
|
17084
|
+
| Field | Value |
|
|
17085
|
+
| --- | --- |
|
|
17086
|
+
| Route | [`/docs/bindings/flagship/internals`](/docs/bindings/flagship/internals) |
|
|
17087
|
+
| Group | Bindings |
|
|
17088
|
+
| Navigation title | Flagship internals |
|
|
17089
|
+
| Eyebrow | Under the hood |
|
|
17090
|
+
|
|
17091
|
+
Use this page when you need emitted config, preview behavior, or Cloudflare-specific limits. The overview and example pages stay focused on everyday app code.
|
|
17092
|
+
|
|
17093
|
+
#### At a glance
|
|
17094
|
+
|
|
17095
|
+
| Fact | Value |
|
|
17096
|
+
| --- | --- |
|
|
17097
|
+
| Normalization | Devflare normalizes `bindings.flagship` before emitting Wrangler `flagship` |
|
|
17098
|
+
| Compile target | Wrangler `flagship` |
|
|
17099
|
+
| Preview note | Cloudflare owns real targeting-rule evaluation, flag management, and remote flag state; the local mock returns configured values and otherwise the default. |
|
|
17100
|
+
|
|
17101
|
+
#### How authored config becomes Wrangler config
|
|
17102
|
+
|
|
17103
|
+
The authored config stays camelCase and project-oriented. The compiler translates that into the Wrangler keys Cloudflare expects.
|
|
17104
|
+
|
|
17105
|
+
The emitted output is shown here so the usage pages do not have to explain compiler details.
|
|
17106
|
+
|
|
17107
|
+
##### Example — Flagship config and emitted Wrangler output
|
|
17108
|
+
|
|
17109
|
+
Use this when you need to check how the Devflare config becomes Wrangler-compatible config.
|
|
17110
|
+
|
|
17111
|
+
###### File — devflare.config.ts
|
|
17112
|
+
|
|
17113
|
+
```ts
|
|
17114
|
+
import { defineConfig } from 'devflare/config'
|
|
17115
|
+
|
|
17116
|
+
export default defineConfig({
|
|
17117
|
+
name: 'flagship-worker',
|
|
17118
|
+
bindings: {
|
|
17119
|
+
flagship: {
|
|
17120
|
+
FLAGS: {
|
|
17121
|
+
appId: 'app-id'
|
|
17122
|
+
}
|
|
17123
|
+
}
|
|
17124
|
+
}
|
|
17125
|
+
})
|
|
17126
|
+
```
|
|
17127
|
+
|
|
17128
|
+
###### File — .devflare/wrangler.jsonc
|
|
17129
|
+
|
|
17130
|
+
```json
|
|
17131
|
+
{
|
|
17132
|
+
"flagship": [
|
|
17133
|
+
{ "binding": "FLAGS", "app_id": "app-id" }
|
|
17134
|
+
]
|
|
17135
|
+
}
|
|
17136
|
+
```
|
|
17137
|
+
|
|
17138
|
+
#### What local runtime support covers
|
|
17139
|
+
|
|
17140
|
+
##### Key points
|
|
17141
|
+
|
|
17142
|
+
- Miniflare's Flagship plugin returns each call's default value locally and ignores the flag key (it does not evaluate flag rules), while Devflare's deterministic pure mock (createMockFlagshipBinding({ flags })) returns configured flag values, falling back to the default
|
|
17143
|
+
- The default docs recipe uses `createTestContext()` or `createOfflineEnv()`.
|
|
17144
|
+
- Pure unit tests can use `createMockFlagshipBinding({ flags })` / `createMockEnv({ flagship })` when the test only needs deterministic application behavior.
|
|
17145
|
+
|
|
17146
|
+
#### Compile, preview, and cleanup behavior
|
|
17147
|
+
|
|
17148
|
+
##### Key points
|
|
17149
|
+
|
|
17150
|
+
- Devflare emits Wrangler `flagship` from the native config surface.
|
|
17151
|
+
- Preview and deployment lifecycle stay feature-specific; do not assume all Cloudflare products can be created, cloned, or cleaned up the same way.
|
|
17152
|
+
- Cloudflare owns real targeting-rule evaluation, flag management, and remote flag state; the local mock returns configured values and otherwise the default.
|
|
17153
|
+
|
|
17154
|
+
#### Cloudflare docs vs the Devflare layer
|
|
17155
|
+
|
|
17156
|
+
Cloudflare Workers bindings docs is the platform reference. Use this internals page when you need to compare Cloudflare's product docs with Devflare config, generated env types, local support, and preview behavior for `bindings.flagship`.
|
|
17157
|
+
|
|
17158
|
+
##### Highlights
|
|
17159
|
+
|
|
17160
|
+
- **Cloudflare Workers bindings docs** — Platform reference for the underlying binding contract on Cloudflare Workers. ([link](https://developers.cloudflare.com/workers/runtime-apis/bindings/))
|
|
17161
|
+
|
|
17162
|
+
##### Reference table
|
|
17163
|
+
|
|
17164
|
+
| Question | Cloudflare docs | This Devflare page |
|
|
17165
|
+
| --- | --- | --- |
|
|
17166
|
+
| Primary focus | Platform reference for the underlying binding contract on Cloudflare Workers. | How to author `bindings.flagship`, what the runtime surface looks like, and how Flagship fits a Devflare project. |
|
|
17167
|
+
| Testing and runtime lens | Cloudflare’s docs focus on the raw binding API, product semantics, and platform limits for the binding itself. | Miniflare's Flagship plugin returns each call's default value locally and ignores the flag key (it does not evaluate flag rules), while Devflare's deterministic pure mock (createMockFlagshipBinding({ flags })) returns configured flag values, falling back to the default. Use the Devflare guidance when you need the honest local harness or the right remote gate instead of only the product API shape. |
|
|
17168
|
+
| When to open it | When you need the platform contract, limits, APIs, or account-level product details. | When you are wiring, testing, previewing, or reviewing the binding inside a Devflare app. |
|
|
17169
|
+
|
|
17170
|
+
---
|
|
17171
|
+
|
|
17172
|
+
### Test Flagship the way Devflare expects it to run
|
|
17173
|
+
|
|
17174
|
+
> Test Flagship by choosing the local harness that matches the product boundary instead of reaching for Cloudflare by default.
|
|
17175
|
+
|
|
17176
|
+
| Field | Value |
|
|
17177
|
+
| --- | --- |
|
|
17178
|
+
| Route | [`/docs/bindings/flagship/testing`](/docs/bindings/flagship/testing) |
|
|
17179
|
+
| Group | Bindings |
|
|
17180
|
+
| Navigation title | Testing Flagship |
|
|
17181
|
+
| Eyebrow | Testing |
|
|
17182
|
+
|
|
17183
|
+
The first test should prove application control flow. Escalate to Wrangler remote binding or deployed tests only when the Cloudflare-hosted behavior is the thing under test.
|
|
17184
|
+
|
|
17185
|
+
#### At a glance
|
|
17186
|
+
|
|
17187
|
+
| Fact | Value |
|
|
17188
|
+
| --- | --- |
|
|
17189
|
+
| Best for | application paths where the Worker reads feature flags from the Flagship binding |
|
|
17190
|
+
| Default harness | `createTestContext()` or `createOfflineEnv()` |
|
|
17191
|
+
| Escalate when | The assertion depends on Cloudflare-hosted product behavior rather than the app calling the binding correctly |
|
|
17192
|
+
|
|
17193
|
+
#### Start with the default test loop
|
|
17194
|
+
|
|
17195
|
+
Keep the first test small. Name the binding, call the one method your route uses, and assert the behavior your app owns.
|
|
17196
|
+
|
|
17197
|
+
When Cloudflare owns the interesting behavior, mark that as a remote/deployed lane instead of building a local fake that claims too much.
|
|
17198
|
+
|
|
17199
|
+
##### Example — Pure Flagship flag-reading test
|
|
17200
|
+
|
|
17201
|
+
```ts
|
|
17202
|
+
import { expect, test } from 'bun:test'
|
|
17203
|
+
import { createMockFlagshipBinding } from 'devflare/test'
|
|
17204
|
+
|
|
17205
|
+
test('returns configured flag value', async () => {
|
|
17206
|
+
const flags = createMockFlagshipBinding({ flags: { 'new-checkout': true } })
|
|
17207
|
+
|
|
17208
|
+
expect(await flags.getBooleanValue('new-checkout', false)).toBe(true)
|
|
17209
|
+
})
|
|
17210
|
+
```
|
|
17211
|
+
|
|
17212
|
+
#### The helper surface to remember
|
|
17213
|
+
|
|
17214
|
+
##### Key points
|
|
17215
|
+
|
|
17216
|
+
- Use `createTestContext()` or `createOfflineEnv()` for config-backed local worker tests.
|
|
17217
|
+
- Use `createMockFlagshipBinding({ flags })` / `createMockEnv({ flagship })` for pure unit tests.
|
|
17218
|
+
- Use `shouldSkip` or an explicit integration lane when the test needs Cloudflare credentials or a local Docker/Podman engine.
|
|
17219
|
+
|
|
17220
|
+
#### When to move beyond the default harness
|
|
17221
|
+
|
|
17222
|
+
##### Key points
|
|
17223
|
+
|
|
17224
|
+
- Cloudflare owns real targeting-rule evaluation, flag management, and remote flag state; the local mock returns configured values and otherwise the default.
|
|
17225
|
+
- Do not let a low-fidelity mock become product documentation. Keep mocks framed as application-flow tools.
|
|
17226
|
+
- If a test would mutate paid or remote Cloudflare state, gate it separately from ordinary unit tests.
|
|
17227
|
+
|
|
17228
|
+
> **Warning — Local tests should be honest**
|
|
17229
|
+
>
|
|
17230
|
+
> For Flagship, passing locally means the Devflare contract and app flow are correct. It does not automatically prove every hosted Cloudflare behavior.
|
|
17231
|
+
|
|
17232
|
+
---
|
|
17233
|
+
|
|
17234
|
+
### Use Flagship in a real application path
|
|
17235
|
+
|
|
17236
|
+
> A compact Flagship recipe with config and worker usage in one application path.
|
|
17237
|
+
|
|
17238
|
+
| Field | Value |
|
|
17239
|
+
| --- | --- |
|
|
17240
|
+
| Route | [`/docs/bindings/flagship/example`](/docs/bindings/flagship/example) |
|
|
17241
|
+
| Group | Bindings |
|
|
17242
|
+
| Navigation title | Flagship example |
|
|
17243
|
+
| Eyebrow | Application example |
|
|
17244
|
+
|
|
17245
|
+
Use this as the copyable starter before threading the feature into a larger application.
|
|
17246
|
+
|
|
17247
|
+
#### At a glance
|
|
17248
|
+
|
|
17249
|
+
| Fact | Value |
|
|
17250
|
+
| --- | --- |
|
|
17251
|
+
| Config focus | bindings.flagship |
|
|
17252
|
+
| Runtime shape | `Flagship` |
|
|
17253
|
+
| Best use | application paths where the Worker reads feature flags from the Flagship binding |
|
|
17254
|
+
|
|
17255
|
+
#### Start by wiring the binding clearly in config
|
|
17256
|
+
|
|
17257
|
+
##### Example — Smallest Flagship config
|
|
17258
|
+
|
|
17259
|
+
```ts
|
|
17260
|
+
import { defineConfig } from 'devflare/config'
|
|
17261
|
+
|
|
17262
|
+
export default defineConfig({
|
|
17263
|
+
name: 'flagship-worker',
|
|
17264
|
+
bindings: {
|
|
17265
|
+
flagship: {
|
|
17266
|
+
FLAGS: {
|
|
17267
|
+
appId: 'app-id'
|
|
17268
|
+
}
|
|
17269
|
+
}
|
|
17270
|
+
}
|
|
17271
|
+
})
|
|
17272
|
+
```
|
|
17273
|
+
|
|
17274
|
+
#### Build the application flow around the binding
|
|
17275
|
+
|
|
17276
|
+
Treat this as the app-level Flagship path: the route, event handler, or service module receives a real request and uses the binding to do useful work.
|
|
17277
|
+
|
|
17278
|
+
Keep product limits, remote ownership, and fallback behavior visible in the code around the binding instead of hiding everything behind a vague utility too early.
|
|
17279
|
+
|
|
17280
|
+
##### Key points
|
|
17281
|
+
|
|
17282
|
+
- Keep the first example short enough to paste into a new Worker.
|
|
17283
|
+
- Cloudflare owns real targeting-rule evaluation, flag management, and remote flag state; the local mock returns configured values and otherwise the default.
|
|
17284
|
+
|
|
17285
|
+
##### Example — Read a boolean flag
|
|
17286
|
+
|
|
17287
|
+
```ts
|
|
17288
|
+
import { env } from 'devflare/runtime'
|
|
17289
|
+
|
|
17290
|
+
export async function fetch(): Promise<Response> {
|
|
17291
|
+
const enabled = await env.FLAGS.getBooleanValue('new-checkout', false)
|
|
17292
|
+
|
|
17293
|
+
return Response.json({ enabled })
|
|
17294
|
+
}
|
|
17295
|
+
```
|
|
17296
|
+
|
|
17297
|
+
#### Keep production boundaries visible
|
|
17298
|
+
|
|
17299
|
+
##### Key points
|
|
17300
|
+
|
|
17301
|
+
- Config focus: bindings.flagship.
|
|
17302
|
+
- Runtime shape: `Flagship`.
|
|
17303
|
+
- Best use: application paths where the Worker reads feature flags from the Flagship binding.
|
|
17304
|
+
|
|
17305
|
+
> **Important — Thread this into the next recipe**
|
|
17306
|
+
>
|
|
17307
|
+
> Once this smallest path works, add routing, generated types, and feature-specific abstraction in that order.
|