From 3dd041efbe9bc6b3d3a4d7495a763e9709413e2a Mon Sep 17 00:00:00 2001 From: Matt Silverlock Date: Tue, 27 Jan 2026 14:45:08 -0500 Subject: [PATCH 1/3] multiplayer globe: align with DO best practices --- .../src/client/index.tsx | 122 +++++++++++------- .../src/client/styles.css | 3 +- .../src/server/index.ts | 67 +++++++--- multiplayer-globe-template/src/shared.ts | 11 +- 4 files changed, 139 insertions(+), 64 deletions(-) diff --git a/multiplayer-globe-template/src/client/index.tsx b/multiplayer-globe-template/src/client/index.tsx index a8285ad29..7ddb42d9a 100644 --- a/multiplayer-globe-template/src/client/index.tsx +++ b/multiplayer-globe-template/src/client/index.tsx @@ -5,60 +5,63 @@ import { createRoot } from "react-dom/client"; import createGlobe from "cobe"; import usePartySocket from "partysocket/react"; -// The type of messages we'll be receiving from the server import type { OutgoingMessage } from "../shared"; -import type { LegacyRef } from "react"; -function App() { - // A reference to the canvas element where we'll render the globe - const canvasRef = useRef(); - // The number of markers we're currently displaying +function Globe({ onShuffle }: { onShuffle: () => void }) { + const canvasRef = useRef(null); const [counter, setCounter] = useState(0); - // A map of marker IDs to their positions - // Note that we use a ref because the globe's `onRender` callback - // is called on every animation frame, and we don't want to re-render - // the component on every frame. + // A map of marker IDs to their positions. + // We use a ref because the globe's `onRender` callback is called on every + // animation frame, and we don't want to re-render the component each time. const positions = useRef< - Map< - string, - { - location: [number, number]; - size: number; - } - > + Map >(new Map()); - // Connect to the PartyServer server + const socket = usePartySocket({ room: "default", party: "globe", onMessage(evt) { - const message = JSON.parse(evt.data as string) as OutgoingMessage; - if (message.type === "add-marker") { - // Add the marker to our map + if (typeof evt.data !== "string") { + return; + } + let message: OutgoingMessage; + try { + message = JSON.parse(evt.data) as OutgoingMessage; + } catch { + console.warn("Failed to parse WebSocket message"); + return; + } + + if (message.type === "room-info") { + // Server confirms which shard we connected to + } else if (message.type === "add-marker") { positions.current.set(message.position.id, { location: [message.position.lat, message.position.lng], size: message.position.id === socket.id ? 0.1 : 0.05, }); - // Update the counter setCounter((c) => c + 1); - } else { - // Remove the marker from our map - positions.current.delete(message.id); - // Update the counter - setCounter((c) => c - 1); + } else if (message.type === "remove-marker") { + // Only decrement counter if the marker actually existed + if (positions.current.delete(message.id)) { + setCounter((c) => c - 1); + } + } else if (message.type === "error") { + console.error("Server error:", message.message); } }, }); useEffect(() => { - // The angle of rotation of the globe - // We'll update this on every frame to make the globe spin - let phi = 0; + const canvas = canvasRef.current; + if (!canvas) { + return; + } - const globe = createGlobe(canvasRef.current as HTMLCanvasElement, { + let phi = 0; + const globe = createGlobe(canvas, { devicePixelRatio: 2, - width: 400 * 2, - height: 400 * 2, + width: 600 * 2, + height: 600 * 2, phi: 0, theta: 0, dark: 1, @@ -89,31 +92,62 @@ function App() { }, []); return ( -
+

Where's everyone at?

+

+ Real-time multiplayer-like coordination built on{" "} + + Cloudflare Durable Objects + +

{counter !== 0 ? (

- {counter} {counter === 1 ? "person" : "people"} connected. + {counter} {counter === 1 ? "person" : "people"} connected to + your{" "} + { + e.preventDefault(); + onShuffle(); + }} + > + shard + + .

) : (

 

)} - {/* The canvas where we'll render the globe */} } - style={{ width: 400, height: 400, maxWidth: "100%", aspectRatio: 1 }} + ref={canvasRef} + style={{ width: 600, height: 600, maxWidth: "90vw", aspectRatio: 1 }} /> - {/* Let's give some credit */} -

- Powered by 🌏 Cobe,{" "} +

+ Powered by Cobe,{" "} Phenomenon and{" "} - 🎈 PartyServer + PartyServer

); } -// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -createRoot(document.getElementById("root")!).render(); +// App wrapper that remounts Globe component to force reconnection to a new shard +function App() { + const [key, setKey] = useState(0); + return setKey((k) => k + 1)} />; +} + +const root = document.getElementById("root"); +if (root) { + createRoot(root).render(); +} diff --git a/multiplayer-globe-template/src/client/styles.css b/multiplayer-globe-template/src/client/styles.css index 672ce9049..c8fc4ac56 100644 --- a/multiplayer-globe-template/src/client/styles.css +++ b/multiplayer-globe-template/src/client/styles.css @@ -14,6 +14,7 @@ body { background-color: black; text-align: center; padding-top: 40px; + margin: 0; } h1, @@ -30,7 +31,7 @@ h6 { } #app { - padding: 1rem; + padding: 0; } h1 { diff --git a/multiplayer-globe-template/src/server/index.ts b/multiplayer-globe-template/src/server/index.ts index ca95d34c9..9e48421f3 100644 --- a/multiplayer-globe-template/src/server/index.ts +++ b/multiplayer-globe-template/src/server/index.ts @@ -9,49 +9,67 @@ type ConnectionState = { }; export class Globe extends Server { - onConnect(conn: Connection, ctx: ConnectionContext) { - // Whenever a fresh connection is made, we'll - // send the entire state to the new connection + onConnect(conn: Connection, ctx: ConnectionContext): void { + // Send room info so the client knows which shard they're in + conn.send( + JSON.stringify({ + type: "room-info", + room: this.name, + } satisfies OutgoingMessage), + ); - // First, let's extract the position from the Cloudflare headers + // Extract position from Cloudflare geolocation headers const latitude = ctx.request.cf?.latitude as string | undefined; const longitude = ctx.request.cf?.longitude as string | undefined; if (!latitude || !longitude) { - console.warn(`Missing position information for connection ${conn.id}`); + conn.send( + JSON.stringify({ + type: "error", + message: "Could not determine your location", + } satisfies OutgoingMessage), + ); + conn.close(4000, "Missing geolocation"); return; } - const position = { + const position: Position = { lat: parseFloat(latitude), lng: parseFloat(longitude), id: conn.id, }; - // And save this on the connection's state - conn.setState({ - position, - }); + conn.setState({ position }); - // Now, let's send the entire state to the new connection + // Send existing markers to the new connection, and notify others of the new user for (const connection of this.getConnections()) { + // Skip connections that don't have position state yet (early return in onConnect) + const connectionPosition = connection.state?.position; + if (!connectionPosition) { + continue; + } + try { conn.send( JSON.stringify({ type: "add-marker", - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - position: connection.state!.position, + position: connectionPosition, } satisfies OutgoingMessage), ); + } catch { + // New connection failed to receive - it will trigger onClose/onError + return; + } - // And let's send the new connection's position to all other connections - if (connection.id !== conn.id) { + // Send the new connection's position to all other connections + if (connection.id !== conn.id) { + try { connection.send( JSON.stringify({ type: "add-marker", position, } satisfies OutgoingMessage), ); + } catch { + this.onCloseOrError(connection); } - } catch { - this.onCloseOrError(conn); } } } @@ -77,8 +95,23 @@ export class Globe extends Server { } } +// Shard users across multiple DO instances to avoid single-DO bottleneck. +// See: https://developers.cloudflare.com/durable-objects/best-practices/ +const MAX_GLOBES = 10; + export default { async fetch(request: Request, env: Env): Promise { + // For WebSocket upgrades, randomly assign to a globe instance. + // PartyServer routes based on the room name in the URL path. + if (request.headers.get("Upgrade") === "websocket") { + const url = new URL(request.url); + if (url.pathname.endsWith("/default")) { + const globe = Math.floor(Math.random() * MAX_GLOBES); + url.pathname = url.pathname.replace(/\/default$/, `/globe-${globe}`); + request = new Request(url, request); + } + } + return ( (await routePartykitRequest(request, { ...env })) || new Response("Not Found", { status: 404 }) diff --git a/multiplayer-globe-template/src/shared.ts b/multiplayer-globe-template/src/shared.ts index 608417525..b7b26b42a 100644 --- a/multiplayer-globe-template/src/shared.ts +++ b/multiplayer-globe-template/src/shared.ts @@ -1,6 +1,5 @@ -// Messages that we'll send to the client +// Messages sent from server to client -// Representing a person's position export type Position = { lat: number; lng: number; @@ -8,6 +7,10 @@ export type Position = { }; export type OutgoingMessage = + | { + type: "room-info"; + room: string; + } | { type: "add-marker"; position: Position; @@ -15,4 +18,8 @@ export type OutgoingMessage = | { type: "remove-marker"; id: string; + } + | { + type: "error"; + message: string; }; From ce1af9baa3fc49f8640573b78a0acbbe1478621c Mon Sep 17 00:00:00 2001 From: Matt Silverlock Date: Tue, 27 Jan 2026 14:47:29 -0500 Subject: [PATCH 2/3] update links --- multiplayer-globe-template/src/client/index.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/multiplayer-globe-template/src/client/index.tsx b/multiplayer-globe-template/src/client/index.tsx index 7ddb42d9a..d69fcf4ee 100644 --- a/multiplayer-globe-template/src/client/index.tsx +++ b/multiplayer-globe-template/src/client/index.tsx @@ -104,7 +104,7 @@ function Globe({ onShuffle }: { onShuffle: () => void }) {

Where's everyone at?

Real-time multiplayer-like coordination built on{" "} - + Cloudflare Durable Objects

@@ -135,7 +135,10 @@ function Globe({ onShuffle }: { onShuffle: () => void }) {

Powered by Cobe,{" "} Phenomenon and{" "} - PartyServer + PartyServer.{" "} + + Code +

); From ae90c001978cd651c356af6883e486338c93ca06 Mon Sep 17 00:00:00 2001 From: Matt Silverlock Date: Tue, 27 Jan 2026 14:47:56 -0500 Subject: [PATCH 3/3] update links --- astro-blog-starter-template/wrangler.json | 26 ++- chanfana-openapi-template/wrangler.jsonc | 28 +-- containers-template/wrangler.jsonc | 64 +++--- .../wrangler.jsonc | 38 ++-- d1-template/wrangler.json | 28 +-- durable-chat-template/wrangler.json | 60 ++--- hello-world-do-template/wrangler.json | 46 ++-- llm-chat-app-template/wrangler.jsonc | 35 +-- microfrontend-template/wrangler.jsonc | 60 ++--- .../src/client/index.tsx | 2 +- multiplayer-globe-template/wrangler.json | 56 ++--- mysql-hyperdrive-template/wrangler.jsonc | 42 ++-- next-starter-template/wrangler.jsonc | 29 +-- nlweb-template/wrangler.jsonc | 98 ++++---- nodejs-http-server-template/wrangler.jsonc | 20 +- openauth-template/wrangler.json | 44 ++-- postgres-hyperdrive-template/wrangler.jsonc | 62 ++--- r2-explorer-template/wrangler.json | 40 ++-- .../wrangler.jsonc | 40 ++-- .../wrangler.jsonc | 42 ++-- .../wrangler.jsonc | 56 ++--- react-router-starter-template/wrangler.json | 26 ++- remix-starter-template/wrangler.json | 20 +- saas-admin-template/wrangler.jsonc | 4 +- text-to-image-template/wrangler.json | 20 +- to-do-list-kv-template/wrangler.jsonc | 38 ++-- vite-react-template/wrangler.json | 28 +-- worker-publisher-template/wrangler.jsonc | 38 ++-- .../wrangler.jsonc | 44 ++-- workers-for-platforms-template/wrangler.jsonc | 90 ++++---- workflows-starter-template/wrangler.jsonc | 74 +++--- x402-proxy-template/wrangler.jsonc | 212 +++++++++--------- 32 files changed, 779 insertions(+), 731 deletions(-) diff --git a/astro-blog-starter-template/wrangler.json b/astro-blog-starter-template/wrangler.json index d08894ab0..c66c540b4 100644 --- a/astro-blog-starter-template/wrangler.json +++ b/astro-blog-starter-template/wrangler.json @@ -1,14 +1,16 @@ { - "name": "astro-blog-starter-template", - "compatibility_date": "2025-10-08", - "compatibility_flags": ["nodejs_compat"], - "main": "./dist/_worker.js/index.js", - "assets": { - "directory": "./dist", - "binding": "ASSETS" - }, - "observability": { - "enabled": true - }, - "upload_source_maps": true + "name": "astro-blog-starter-template", + "compatibility_date": "2025-10-08", + "compatibility_flags": [ + "nodejs_compat" + ], + "main": "./dist/_worker.js/index.js", + "assets": { + "directory": "./dist", + "binding": "ASSETS" + }, + "observability": { + "enabled": true + }, + "upload_source_maps": true } diff --git a/chanfana-openapi-template/wrangler.jsonc b/chanfana-openapi-template/wrangler.jsonc index a96fedec8..dbbdd4bd9 100644 --- a/chanfana-openapi-template/wrangler.jsonc +++ b/chanfana-openapi-template/wrangler.jsonc @@ -1,16 +1,16 @@ { - "compatibility_date": "2025-10-08", - "main": "src/index.ts", - "name": "chanfana-openapi-template", - "upload_source_maps": true, - "observability": { - "enabled": true - }, - "d1_databases": [ - { - "binding": "DB", - "database_name": "openapi-template-db", - "database_id": "18d141d5-062d-46a0-a92a-bade3f8c4b00" - } - ] + "compatibility_date": "2025-10-08", + "main": "src/index.ts", + "name": "chanfana-openapi-template", + "upload_source_maps": true, + "observability": { + "enabled": true + }, + "d1_databases": [ + { + "binding": "DB", + "database_name": "openapi-template-db", + "database_id": "18d141d5-062d-46a0-a92a-bade3f8c4b00" + } + ] } diff --git a/containers-template/wrangler.jsonc b/containers-template/wrangler.jsonc index 312c7f4d9..3db5a2ef0 100644 --- a/containers-template/wrangler.jsonc +++ b/containers-template/wrangler.jsonc @@ -1,32 +1,36 @@ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "containers-template", - "main": "src/index.ts", - "compatibility_date": "2025-10-08", - "compatibility_flags": ["nodejs_compat"], - "observability": { - "enabled": true - }, - "containers": [ - { - "class_name": "MyContainer", - "image": "./Dockerfile", - "max_instances": 10 - } - ], - "durable_objects": { - "bindings": [ - { - "class_name": "MyContainer", - "name": "MY_CONTAINER" - } - ] - }, - "migrations": [ - { - "new_sqlite_classes": ["MyContainer"], - "tag": "v1" - } - ], - "upload_source_maps": true + "$schema": "node_modules/wrangler/config-schema.json", + "name": "containers-template", + "main": "src/index.ts", + "compatibility_date": "2025-10-08", + "compatibility_flags": [ + "nodejs_compat" + ], + "observability": { + "enabled": true + }, + "containers": [ + { + "class_name": "MyContainer", + "image": "./Dockerfile", + "max_instances": 10 + } + ], + "durable_objects": { + "bindings": [ + { + "class_name": "MyContainer", + "name": "MY_CONTAINER" + } + ] + }, + "migrations": [ + { + "new_sqlite_classes": [ + "MyContainer" + ], + "tag": "v1" + } + ], + "upload_source_maps": true } diff --git a/d1-starter-sessions-api-template/wrangler.jsonc b/d1-starter-sessions-api-template/wrangler.jsonc index a74c65b0c..497be7909 100644 --- a/d1-starter-sessions-api-template/wrangler.jsonc +++ b/d1-starter-sessions-api-template/wrangler.jsonc @@ -3,28 +3,28 @@ * https://developers.cloudflare.com/workers/wrangler/configuration/ */ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "d1-starter-sessions-api-template", - "main": "src/index.ts", - "compatibility_date": "2025-10-08", - "observability": { - "enabled": true - }, - "assets": { - "directory": "./public/" - }, - /** + "$schema": "node_modules/wrangler/config-schema.json", + "name": "d1-starter-sessions-api-template", + "main": "src/index.ts", + "compatibility_date": "2025-10-08", + "observability": { + "enabled": true + }, + "assets": { + "directory": "./public/" + }, + /** * Bindings * Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including * databases, object storage, AI inference, real-time communication and more. * https://developers.cloudflare.com/workers/runtime-apis/bindings/ */ - "d1_databases": [ - { - "binding": "DB01", - "database_name": "d1-starter-sessions-api", - "database_id": "3690f364-3425-4fab-8eb7-c74c5717578a" - } - ], - "upload_source_maps": true + "d1_databases": [ + { + "binding": "DB01", + "database_name": "d1-starter-sessions-api", + "database_id": "3690f364-3425-4fab-8eb7-c74c5717578a" + } + ], + "upload_source_maps": true } diff --git a/d1-template/wrangler.json b/d1-template/wrangler.json index ed8d3bbf0..6c304b820 100644 --- a/d1-template/wrangler.json +++ b/d1-template/wrangler.json @@ -1,16 +1,16 @@ { - "compatibility_date": "2025-10-08", - "main": "src/index.ts", - "name": "d1-template", - "upload_source_maps": true, - "d1_databases": [ - { - "binding": "DB", - "database_id": "151f7d9b-365f-41d7-83ed-0bf4eeef5086", - "database_name": "d1-template-database" - } - ], - "observability": { - "enabled": true - } + "compatibility_date": "2025-10-08", + "main": "src/index.ts", + "name": "d1-template", + "upload_source_maps": true, + "d1_databases": [ + { + "binding": "DB", + "database_id": "151f7d9b-365f-41d7-83ed-0bf4eeef5086", + "database_name": "d1-template-database" + } + ], + "observability": { + "enabled": true + } } diff --git a/durable-chat-template/wrangler.json b/durable-chat-template/wrangler.json index 351fde124..3716cd8a2 100644 --- a/durable-chat-template/wrangler.json +++ b/durable-chat-template/wrangler.json @@ -1,31 +1,33 @@ { - "compatibility_date": "2025-10-08", - "main": "src/server/index.ts", - "name": "durable-chat-template", - "migrations": [ - { - "new_sqlite_classes": ["Chat"], - "tag": "v1" - } - ], - "assets": { - "directory": "./public", - "binding": "ASSETS", - "not_found_handling": "single-page-application" - }, - "build": { - "command": "esbuild src/client/index.tsx --bundle --splitting --format=esm --platform=browser --outdir=public/dist" - }, - "durable_objects": { - "bindings": [ - { - "class_name": "Chat", - "name": "Chat" - } - ] - }, - "observability": { - "enabled": true - }, - "upload_source_maps": true + "compatibility_date": "2025-10-08", + "main": "src/server/index.ts", + "name": "durable-chat-template", + "migrations": [ + { + "new_sqlite_classes": [ + "Chat" + ], + "tag": "v1" + } + ], + "assets": { + "directory": "./public", + "binding": "ASSETS", + "not_found_handling": "single-page-application" + }, + "build": { + "command": "esbuild src/client/index.tsx --bundle --splitting --format=esm --platform=browser --outdir=public/dist" + }, + "durable_objects": { + "bindings": [ + { + "class_name": "Chat", + "name": "Chat" + } + ] + }, + "observability": { + "enabled": true + }, + "upload_source_maps": true } diff --git a/hello-world-do-template/wrangler.json b/hello-world-do-template/wrangler.json index 06a8fd105..ff8ad041a 100644 --- a/hello-world-do-template/wrangler.json +++ b/hello-world-do-template/wrangler.json @@ -1,24 +1,26 @@ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "hello-world-do-template", - "main": "src/index.ts", - "compatibility_date": "2025-10-08", - "upload_source_maps": true, - "migrations": [ - { - "new_sqlite_classes": ["MyDurableObject"], - "tag": "v1" - } - ], - "durable_objects": { - "bindings": [ - { - "class_name": "MyDurableObject", - "name": "MY_DURABLE_OBJECT" - } - ] - }, - "observability": { - "enabled": true - } + "$schema": "node_modules/wrangler/config-schema.json", + "name": "hello-world-do-template", + "main": "src/index.ts", + "compatibility_date": "2025-10-08", + "upload_source_maps": true, + "migrations": [ + { + "new_sqlite_classes": [ + "MyDurableObject" + ], + "tag": "v1" + } + ], + "durable_objects": { + "bindings": [ + { + "class_name": "MyDurableObject", + "name": "MY_DURABLE_OBJECT" + } + ] + }, + "observability": { + "enabled": true + } } diff --git a/llm-chat-app-template/wrangler.jsonc b/llm-chat-app-template/wrangler.jsonc index 7c67a6cb6..cbae4c271 100644 --- a/llm-chat-app-template/wrangler.jsonc +++ b/llm-chat-app-template/wrangler.jsonc @@ -3,20 +3,23 @@ * https://developers.cloudflare.com/workers/wrangler/configuration/ */ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "llm-chat-app-template", - "main": "src/index.ts", - "compatibility_date": "2025-10-08", - "compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public"], - "assets": { - "binding": "ASSETS", - "directory": "./public" - }, - "observability": { - "enabled": true - }, - "ai": { - "binding": "AI" - }, - "upload_source_maps": true + "$schema": "node_modules/wrangler/config-schema.json", + "name": "llm-chat-app-template", + "main": "src/index.ts", + "compatibility_date": "2025-10-08", + "compatibility_flags": [ + "nodejs_compat", + "global_fetch_strictly_public" + ], + "assets": { + "binding": "ASSETS", + "directory": "./public" + }, + "observability": { + "enabled": true + }, + "ai": { + "binding": "AI" + }, + "upload_source_maps": true } diff --git a/microfrontend-template/wrangler.jsonc b/microfrontend-template/wrangler.jsonc index be1ce89f7..e8ce3fff3 100644 --- a/microfrontend-template/wrangler.jsonc +++ b/microfrontend-template/wrangler.jsonc @@ -1,31 +1,33 @@ { - "$schema": "./node_modules/wrangler/config-schema.json", - "name": "microfrontend-template", - "main": "./index.ts", - "compatibility_date": "2025-10-08", - "compatibility_flags": ["nodejs_compat"], - "workers_dev": true, - "routes": [ - { - "pattern": "example.com/*", - "zone_name": "example.com" - } - ], - "services": [ - { - "binding": "APP1", - "service": "worker-a" - }, - { - "binding": "APP2", - "service": "worker-b" - } - ], - "vars": { - "ROUTES": "{\"smoothTransitions\":true, \"routes\":[{\"binding\": \"APP1\", \"path\": \"/app1\", \"preload\":true}, {\"binding\": \"APP2\", \"path\": \"/app2\"}]}" - }, - "observability": { - "enabled": true - }, - "upload_source_maps": true + "$schema": "./node_modules/wrangler/config-schema.json", + "name": "microfrontend-template", + "main": "./index.ts", + "compatibility_date": "2025-10-08", + "compatibility_flags": [ + "nodejs_compat" + ], + "workers_dev": true, + "routes": [ + { + "pattern": "example.com/*", + "zone_name": "example.com" + } + ], + "services": [ + { + "binding": "APP1", + "service": "worker-a" + }, + { + "binding": "APP2", + "service": "worker-b" + } + ], + "vars": { + "ROUTES": "{\"smoothTransitions\":true, \"routes\":[{\"binding\": \"APP1\", \"path\": \"/app1\", \"preload\":true}, {\"binding\": \"APP2\", \"path\": \"/app2\"}]}" + }, + "observability": { + "enabled": true + }, + "upload_source_maps": true } diff --git a/multiplayer-globe-template/src/client/index.tsx b/multiplayer-globe-template/src/client/index.tsx index d69fcf4ee..8c8c305b6 100644 --- a/multiplayer-globe-template/src/client/index.tsx +++ b/multiplayer-globe-template/src/client/index.tsx @@ -137,7 +137,7 @@ function Globe({ onShuffle }: { onShuffle: () => void }) { Phenomenon and{" "} PartyServer.{" "} - Code + Source code

diff --git a/multiplayer-globe-template/wrangler.json b/multiplayer-globe-template/wrangler.json index c0881c4b7..831590151 100644 --- a/multiplayer-globe-template/wrangler.json +++ b/multiplayer-globe-template/wrangler.json @@ -1,29 +1,31 @@ { - "compatibility_date": "2025-10-08", - "main": "src/server/index.ts", - "name": "multiplayer-globe-template", - "migrations": [ - { - "new_sqlite_classes": ["Globe"], - "tag": "v1" - } - ], - "assets": { - "directory": "public" - }, - "build": { - "command": "npx esbuild src/client/index.tsx --bundle --outdir=public/dist --splitting --sourcemap --format=esm" - }, - "durable_objects": { - "bindings": [ - { - "class_name": "Globe", - "name": "Globe" - } - ] - }, - "observability": { - "enabled": true - }, - "upload_source_maps": true + "compatibility_date": "2025-10-08", + "main": "src/server/index.ts", + "name": "multiplayer-globe-template", + "migrations": [ + { + "new_sqlite_classes": [ + "Globe" + ], + "tag": "v1" + } + ], + "assets": { + "directory": "public" + }, + "build": { + "command": "npx esbuild src/client/index.tsx --bundle --outdir=public/dist --splitting --sourcemap --format=esm" + }, + "durable_objects": { + "bindings": [ + { + "class_name": "Globe", + "name": "Globe" + } + ] + }, + "observability": { + "enabled": true + }, + "upload_source_maps": true } diff --git a/mysql-hyperdrive-template/wrangler.jsonc b/mysql-hyperdrive-template/wrangler.jsonc index 2e3c65954..ff506ba96 100644 --- a/mysql-hyperdrive-template/wrangler.jsonc +++ b/mysql-hyperdrive-template/wrangler.jsonc @@ -1,22 +1,24 @@ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "mysql-hyperdrive-template", - "main": "src/index.ts", - "compatibility_date": "2025-10-08", - "compatibility_flags": ["nodejs_compat"], - "observability": { - "enabled": true - }, - "hyperdrive": [ - { - "binding": "HYPERDRIVE", - "id": "7668c461af3c47969772c19cbd988391", // Replace with your Hyperdrive ID - "localConnectionString": "mysql://username:password@mysql-domain.com:3306/defaultdb" // Replace with your connection string - } - ], - "assets": { - "directory": "public", - "binding": "ASSETS" - }, - "upload_source_maps": true + "$schema": "node_modules/wrangler/config-schema.json", + "name": "mysql-hyperdrive-template", + "main": "src/index.ts", + "compatibility_date": "2025-10-08", + "compatibility_flags": [ + "nodejs_compat" + ], + "observability": { + "enabled": true + }, + "hyperdrive": [ + { + "binding": "HYPERDRIVE", + "id": "7668c461af3c47969772c19cbd988391", // Replace with your Hyperdrive ID + "localConnectionString": "mysql://username:password@mysql-domain.com:3306/defaultdb" // Replace with your connection string + } + ], + "assets": { + "directory": "public", + "binding": "ASSETS" + }, + "upload_source_maps": true } diff --git a/next-starter-template/wrangler.jsonc b/next-starter-template/wrangler.jsonc index 8e0d3cf85..febfae14d 100644 --- a/next-starter-template/wrangler.jsonc +++ b/next-starter-template/wrangler.jsonc @@ -3,17 +3,20 @@ * https://developers.cloudflare.com/workers/wrangler/configuration/ */ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "next-starter-template", - "main": ".open-next/worker.js", - "compatibility_date": "2025-10-08", - "compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public"], - "assets": { - "binding": "ASSETS", - "directory": ".open-next/assets" - }, - "observability": { - "enabled": true - }, - "upload_source_maps": true + "$schema": "node_modules/wrangler/config-schema.json", + "name": "next-starter-template", + "main": ".open-next/worker.js", + "compatibility_date": "2025-10-08", + "compatibility_flags": [ + "nodejs_compat", + "global_fetch_strictly_public" + ], + "assets": { + "binding": "ASSETS", + "directory": ".open-next/assets" + }, + "observability": { + "enabled": true + }, + "upload_source_maps": true } diff --git a/nlweb-template/wrangler.jsonc b/nlweb-template/wrangler.jsonc index 5526fa51f..6abc70964 100644 --- a/nlweb-template/wrangler.jsonc +++ b/nlweb-template/wrangler.jsonc @@ -1,49 +1,53 @@ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "nlweb-template", - "main": "src/index.ts", - "compatibility_date": "2025-10-08", - "compatibility_flags": ["nodejs_compat"], - "observability": { - "enabled": true - }, - "assets": { - "directory": "./public", - "binding": "ASSETS", - "run_worker_first": true - }, - "vars": { - "RAG_ID": "my-autorag-id" - }, - "ai": { - "binding": "AI" - }, - "unsafe": { - "bindings": [ - { - "name": "RATE_LIMITER", - "type": "ratelimit", - "namespace_id": "100", - "simple": { - "limit": 15, - "period": 60 - } - } - ] - }, - "migrations": [ - { - "new_sqlite_classes": ["NLWebMcp"], - "tag": "v1" - } - ], - "durable_objects": { - "bindings": [ - { - "class_name": "NLWebMcp", - "name": "MCP_OBJECT" - } - ] - }, - "upload_source_maps": true + "$schema": "node_modules/wrangler/config-schema.json", + "name": "nlweb-template", + "main": "src/index.ts", + "compatibility_date": "2025-10-08", + "compatibility_flags": [ + "nodejs_compat" + ], + "observability": { + "enabled": true + }, + "assets": { + "directory": "./public", + "binding": "ASSETS", + "run_worker_first": true + }, + "vars": { + "RAG_ID": "my-autorag-id" + }, + "ai": { + "binding": "AI" + }, + "unsafe": { + "bindings": [ + { + "name": "RATE_LIMITER", + "type": "ratelimit", + "namespace_id": "100", + "simple": { + "limit": 15, + "period": 60 + } + } + ] + }, + "migrations": [ + { + "new_sqlite_classes": [ + "NLWebMcp" + ], + "tag": "v1" + } + ], + "durable_objects": { + "bindings": [ + { + "class_name": "NLWebMcp", + "name": "MCP_OBJECT" + } + ] + }, + "upload_source_maps": true } diff --git a/nodejs-http-server-template/wrangler.jsonc b/nodejs-http-server-template/wrangler.jsonc index d24468da2..fa4fb42e7 100644 --- a/nodejs-http-server-template/wrangler.jsonc +++ b/nodejs-http-server-template/wrangler.jsonc @@ -1,11 +1,13 @@ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "nodejs-http-server-template", - "main": "src/index.ts", - "compatibility_date": "2025-10-08", - "compatibility_flags": ["nodejs_compat"], - "observability": { - "enabled": true - }, - "upload_source_maps": true + "$schema": "node_modules/wrangler/config-schema.json", + "name": "nodejs-http-server-template", + "main": "src/index.ts", + "compatibility_date": "2025-10-08", + "compatibility_flags": [ + "nodejs_compat" + ], + "observability": { + "enabled": true + }, + "upload_source_maps": true } diff --git a/openauth-template/wrangler.json b/openauth-template/wrangler.json index 5828b6d8e..55ad959a0 100644 --- a/openauth-template/wrangler.json +++ b/openauth-template/wrangler.json @@ -1,23 +1,25 @@ { - "compatibility_date": "2025-10-08", - "main": "src/index.ts", - "name": "openauth-template", - "upload_source_maps": true, - "kv_namespaces": [ - { - "binding": "AUTH_STORAGE", - "id": "afec91ff3f7e4b0b9b9323fc6cf5ff85" - } - ], - "d1_databases": [ - { - "binding": "AUTH_DB", - "database_name": "openauth-template-auth-db", - "database_id": "d4dfb2e9-2fd3-4d04-9c83-57b4336a5958" - } - ], - "observability": { - "enabled": true - }, - "compatibility_flags": ["nodejs_compat"] + "compatibility_date": "2025-10-08", + "main": "src/index.ts", + "name": "openauth-template", + "upload_source_maps": true, + "kv_namespaces": [ + { + "binding": "AUTH_STORAGE", + "id": "afec91ff3f7e4b0b9b9323fc6cf5ff85" + } + ], + "d1_databases": [ + { + "binding": "AUTH_DB", + "database_name": "openauth-template-auth-db", + "database_id": "d4dfb2e9-2fd3-4d04-9c83-57b4336a5958" + } + ], + "observability": { + "enabled": true + }, + "compatibility_flags": [ + "nodejs_compat" + ] } diff --git a/postgres-hyperdrive-template/wrangler.jsonc b/postgres-hyperdrive-template/wrangler.jsonc index bb628e6f1..568af5680 100644 --- a/postgres-hyperdrive-template/wrangler.jsonc +++ b/postgres-hyperdrive-template/wrangler.jsonc @@ -3,54 +3,56 @@ * https://developers.cloudflare.com/workers/wrangler/configuration/ */ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "postgres-hyperdrive-template", - "main": "src/index.ts", - "compatibility_date": "2025-10-08", - "compatibility_flags": ["nodejs_compat"], - "observability": { - "enabled": true - }, - "hyperdrive": [ - { - "binding": "HYPERDRIVE", - "id": "7853460cd9194ddb864cc211f3fc6e68", - "localConnectionString": "postgresql://postgres:postgres@localhost:5432/defaultdb" // Replace with your connection string - } - ], - "assets": { - "directory": "public", - "binding": "ASSETS" - }, - /** + "$schema": "node_modules/wrangler/config-schema.json", + "name": "postgres-hyperdrive-template", + "main": "src/index.ts", + "compatibility_date": "2025-10-08", + "compatibility_flags": [ + "nodejs_compat" + ], + "observability": { + "enabled": true + }, + "hyperdrive": [ + { + "binding": "HYPERDRIVE", + "id": "7853460cd9194ddb864cc211f3fc6e68", + "localConnectionString": "postgresql://postgres:postgres@localhost:5432/defaultdb" // Replace with your connection string + } + ], + "assets": { + "directory": "public", + "binding": "ASSETS" + }, + /** * Smart Placement * Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement */ - // "placement": { "mode": "smart" }, - /** + // "placement": { "mode": "smart" }, + /** * Bindings * Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including * databases, object storage, AI inference, real-time communication and more. * https://developers.cloudflare.com/workers/runtime-apis/bindings/ */ - /** + /** * Environment Variables * https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables */ - // "vars": { "MY_VARIABLE": "production_value" }, - /** + // "vars": { "MY_VARIABLE": "production_value" }, + /** * Note: Use secrets to store sensitive data. * https://developers.cloudflare.com/workers/configuration/secrets/ */ - /** + /** * Static Assets * https://developers.cloudflare.com/workers/static-assets/binding/ */ - // "assets": { "directory": "./public/", "binding": "ASSETS" }, - /** + // "assets": { "directory": "./public/", "binding": "ASSETS" }, + /** * Service Bindings (communicate between multiple Workers) * https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings */ - // "services": [{ "binding": "MY_SERVICE", "service": "my-service" }] - "upload_source_maps": true + // "services": [{ "binding": "MY_SERVICE", "service": "my-service" }] + "upload_source_maps": true } diff --git a/r2-explorer-template/wrangler.json b/r2-explorer-template/wrangler.json index 3f5633d7b..cced89d7d 100644 --- a/r2-explorer-template/wrangler.json +++ b/r2-explorer-template/wrangler.json @@ -1,22 +1,22 @@ { - "compatibility_date": "2025-10-08", - "main": "src/index.ts", - "name": "r2-explorer-template", - "assets": { - "directory": "node_modules/r2-explorer/dashboard", - "binding": "ASSETS", - "html_handling": "auto-trailing-slash", - "not_found_handling": "single-page-application" - }, - "r2_buckets": [ - { - "binding": "bucket", - "bucket_name": "r2-explorer-bucket", - "preview_bucket_name": "r2-explorer-bucket" - } - ], - "observability": { - "enabled": true - }, - "upload_source_maps": true + "compatibility_date": "2025-10-08", + "main": "src/index.ts", + "name": "r2-explorer-template", + "assets": { + "directory": "node_modules/r2-explorer/dashboard", + "binding": "ASSETS", + "html_handling": "auto-trailing-slash", + "not_found_handling": "single-page-application" + }, + "r2_buckets": [ + { + "binding": "bucket", + "bucket_name": "r2-explorer-bucket", + "preview_bucket_name": "r2-explorer-bucket" + } + ], + "observability": { + "enabled": true + }, + "upload_source_maps": true } diff --git a/react-postgres-fullstack-template/wrangler.jsonc b/react-postgres-fullstack-template/wrangler.jsonc index 272074fa9..ebdfd6e02 100644 --- a/react-postgres-fullstack-template/wrangler.jsonc +++ b/react-postgres-fullstack-template/wrangler.jsonc @@ -3,21 +3,23 @@ * https://developers.cloudflare.com/workers/wrangler/configuration/ */ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "react-postgres-fullstack-template", - "main": "api/index.js", - "compatibility_flags": ["nodejs_compat"], - "compatibility_date": "2025-10-08", - "observability": { - "enabled": true - }, - "assets": { - "binding": "ASSETS", - "not_found_handling": "single-page-application" - }, - // Hyperdrive binding is optional - if not provided, app will use mock data - // To enable Hyperdrive, uncomment and configure properly: - /* + "$schema": "node_modules/wrangler/config-schema.json", + "name": "react-postgres-fullstack-template", + "main": "api/index.js", + "compatibility_flags": [ + "nodejs_compat" + ], + "compatibility_date": "2025-10-08", + "observability": { + "enabled": true + }, + "assets": { + "binding": "ASSETS", + "not_found_handling": "single-page-application" + }, + // Hyperdrive binding is optional - if not provided, app will use mock data + // To enable Hyperdrive, uncomment and configure properly: + /* "hyperdrive": [ { "binding": "HYPERDRIVE", @@ -26,8 +28,8 @@ } ], */ - "placement": { - "mode": "smart" - }, - "upload_source_maps": true + "placement": { + "mode": "smart" + }, + "upload_source_maps": true } diff --git a/react-router-hono-fullstack-template/wrangler.jsonc b/react-router-hono-fullstack-template/wrangler.jsonc index d0594482a..320e1ec7a 100644 --- a/react-router-hono-fullstack-template/wrangler.jsonc +++ b/react-router-hono-fullstack-template/wrangler.jsonc @@ -3,45 +3,45 @@ * https://developers.cloudflare.com/workers/wrangler/configuration/ */ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "react-router-hono-fullstack-template", - "compatibility_date": "2025-10-08", - "main": "./workers/app.ts", - "vars": { - "VALUE_FROM_CLOUDFLARE": "Hello from Hono/CF" - }, - "observability": { - "enabled": true - }, - /** + "$schema": "node_modules/wrangler/config-schema.json", + "name": "react-router-hono-fullstack-template", + "compatibility_date": "2025-10-08", + "main": "./workers/app.ts", + "vars": { + "VALUE_FROM_CLOUDFLARE": "Hello from Hono/CF" + }, + "observability": { + "enabled": true + }, + /** * Smart Placement * Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement */ - // "placement": { "mode": "smart" }, - /** + // "placement": { "mode": "smart" }, + /** * Bindings * Bindings allow your Worker to interact with resources on the Cloudflare Developer Platform, including * databases, object storage, AI inference, real-time communication and more. * https://developers.cloudflare.com/workers/runtime-apis/bindings/ */ - /** + /** * Environment Variables * https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables */ - // "vars": { "MY_VARIABLE": "production_value" }, - /** + // "vars": { "MY_VARIABLE": "production_value" }, + /** * Note: Use secrets to store sensitive data. * https://developers.cloudflare.com/workers/configuration/secrets/ */ - /** + /** * Static Assets * https://developers.cloudflare.com/workers/static-assets/binding/ */ - // "assets": { "directory": "./public/", "binding": "ASSETS" }, - /** + // "assets": { "directory": "./public/", "binding": "ASSETS" }, + /** * Service Bindings (communicate between multiple Workers) * https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings */ - // "services": [{ "binding": "MY_SERVICE", "service": "my-service" }] - "upload_source_maps": true + // "services": [{ "binding": "MY_SERVICE", "service": "my-service" }] + "upload_source_maps": true } diff --git a/react-router-postgres-ssr-template/wrangler.jsonc b/react-router-postgres-ssr-template/wrangler.jsonc index 4814886c1..8bbb4a625 100644 --- a/react-router-postgres-ssr-template/wrangler.jsonc +++ b/react-router-postgres-ssr-template/wrangler.jsonc @@ -1,29 +1,31 @@ { - "$schema": "./node_modules/wrangler/config-schema.json", - "name": "react-router-postgres-ssr-template", - "compatibility_date": "2025-10-08", - "main": "./api/index.js", - "compatibility_flags": ["nodejs_compat"], - "assets": {}, - // "hyperdrive": [ - // { - // "binding": "HYPERDRIVE", - // "id": "YOUR_HYPERDRIVE_ID", - // "localConnectionString": "postgresql://myuser:mypassword@localhost:5432/mydatabase" - // } - // ], - "services": [ - { - "binding": "BOOKS_SERVICE", - "service": "react-router-postgres-ssr-template", - "entrypoint": "BooksService" - } - ], - "placement": { - "mode": "smart" - }, - "observability": { - "enabled": true - }, - "upload_source_maps": true + "$schema": "./node_modules/wrangler/config-schema.json", + "name": "react-router-postgres-ssr-template", + "compatibility_date": "2025-10-08", + "main": "./api/index.js", + "compatibility_flags": [ + "nodejs_compat" + ], + "assets": {}, + // "hyperdrive": [ + // { + // "binding": "HYPERDRIVE", + // "id": "YOUR_HYPERDRIVE_ID", + // "localConnectionString": "postgresql://myuser:mypassword@localhost:5432/mydatabase" + // } + // ], + "services": [ + { + "binding": "BOOKS_SERVICE", + "service": "react-router-postgres-ssr-template", + "entrypoint": "BooksService" + } + ], + "placement": { + "mode": "smart" + }, + "observability": { + "enabled": true + }, + "upload_source_maps": true } diff --git a/react-router-starter-template/wrangler.json b/react-router-starter-template/wrangler.json index 244cd5e97..97234aaa3 100644 --- a/react-router-starter-template/wrangler.json +++ b/react-router-starter-template/wrangler.json @@ -1,14 +1,16 @@ { - "$schema": "./node_modules/wrangler/config-schema.json", - "name": "react-router-starter-template", - "main": "./workers/app.ts", - "compatibility_date": "2025-10-08", - "compatibility_flags": ["nodejs_compat"], - "observability": { - "enabled": true - }, - "upload_source_maps": true, - "vars": { - "VALUE_FROM_CLOUDFLARE": "Hello from Cloudflare" - } + "$schema": "./node_modules/wrangler/config-schema.json", + "name": "react-router-starter-template", + "main": "./workers/app.ts", + "compatibility_date": "2025-10-08", + "compatibility_flags": [ + "nodejs_compat" + ], + "observability": { + "enabled": true + }, + "upload_source_maps": true, + "vars": { + "VALUE_FROM_CLOUDFLARE": "Hello from Cloudflare" + } } diff --git a/remix-starter-template/wrangler.json b/remix-starter-template/wrangler.json index 35c475c5c..8e51c9429 100644 --- a/remix-starter-template/wrangler.json +++ b/remix-starter-template/wrangler.json @@ -1,12 +1,12 @@ { - "name": "remix-starter-template", - "compatibility_date": "2025-10-08", - "main": "./server.ts", - "assets": { - "directory": "./build/client" - }, - "observability": { - "enabled": true - }, - "upload_source_maps": true + "name": "remix-starter-template", + "compatibility_date": "2025-10-08", + "main": "./server.ts", + "assets": { + "directory": "./build/client" + }, + "observability": { + "enabled": true + }, + "upload_source_maps": true } diff --git a/saas-admin-template/wrangler.jsonc b/saas-admin-template/wrangler.jsonc index 27bcf97c3..d11377396 100644 --- a/saas-admin-template/wrangler.jsonc +++ b/saas-admin-template/wrangler.jsonc @@ -5,7 +5,9 @@ "directory": "./dist" }, "compatibility_date": "2025-10-08", - "compatibility_flags": ["nodejs_compat"], + "compatibility_flags": [ + "nodejs_compat" + ], "observability": { "enabled": true }, diff --git a/text-to-image-template/wrangler.json b/text-to-image-template/wrangler.json index 743500652..1d292a7be 100644 --- a/text-to-image-template/wrangler.json +++ b/text-to-image-template/wrangler.json @@ -1,12 +1,12 @@ { - "compatibility_date": "2025-10-08", - "main": "src/index.ts", - "name": "text-to-image-template", - "upload_source_maps": true, - "ai": { - "binding": "AI" - }, - "observability": { - "enabled": true - } + "compatibility_date": "2025-10-08", + "main": "src/index.ts", + "name": "text-to-image-template", + "upload_source_maps": true, + "ai": { + "binding": "AI" + }, + "observability": { + "enabled": true + } } diff --git a/to-do-list-kv-template/wrangler.jsonc b/to-do-list-kv-template/wrangler.jsonc index a7175c3b4..ebc5706b4 100644 --- a/to-do-list-kv-template/wrangler.jsonc +++ b/to-do-list-kv-template/wrangler.jsonc @@ -1,20 +1,22 @@ { - "$schema": "./node_modules/wrangler/config-schema.json", - "name": "to-do-list-kv-template", - "compatibility_date": "2025-10-08", - "upload_source_maps": true, - "main": "./server.ts", - "assets": { - "directory": "./build/client" - }, - "compatibility_flags": ["nodejs_compat"], - "observability": { - "enabled": true - }, - "kv_namespaces": [ - { - "binding": "TO_DO_LIST", - "id": "cf8aa41453dc4be09ff86530895773e1" - } - ] + "$schema": "./node_modules/wrangler/config-schema.json", + "name": "to-do-list-kv-template", + "compatibility_date": "2025-10-08", + "upload_source_maps": true, + "main": "./server.ts", + "assets": { + "directory": "./build/client" + }, + "compatibility_flags": [ + "nodejs_compat" + ], + "observability": { + "enabled": true + }, + "kv_namespaces": [ + { + "binding": "TO_DO_LIST", + "id": "cf8aa41453dc4be09ff86530895773e1" + } + ] } diff --git a/vite-react-template/wrangler.json b/vite-react-template/wrangler.json index dd397d4de..477ebd491 100644 --- a/vite-react-template/wrangler.json +++ b/vite-react-template/wrangler.json @@ -1,15 +1,17 @@ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "vite-react-template", - "main": "./src/worker/index.ts", - "compatibility_date": "2025-10-08", - "compatibility_flags": ["nodejs_compat"], - "observability": { - "enabled": true - }, - "upload_source_maps": true, - "assets": { - "directory": "./dist/client", - "not_found_handling": "single-page-application" - } + "$schema": "node_modules/wrangler/config-schema.json", + "name": "vite-react-template", + "main": "./src/worker/index.ts", + "compatibility_date": "2025-10-08", + "compatibility_flags": [ + "nodejs_compat" + ], + "observability": { + "enabled": true + }, + "upload_source_maps": true, + "assets": { + "directory": "./dist/client", + "not_found_handling": "single-page-application" + } } diff --git a/worker-publisher-template/wrangler.jsonc b/worker-publisher-template/wrangler.jsonc index 8947ff632..b9d5ce506 100644 --- a/worker-publisher-template/wrangler.jsonc +++ b/worker-publisher-template/wrangler.jsonc @@ -1,21 +1,21 @@ { - "$schema": "./node_modules/wrangler/config-schema.json", - "name": "worker-publisher-template", - "main": "./src/index.ts", - "compatibility_date": "2025-10-08", - "upload_source_maps": true, - "dispatch_namespaces": [ - { - "binding": "DISPATCHER", - "namespace": "my-dispatch-namespace", - "remote": true - } - ], - "observability": { - "enabled": true - }, - "vars": { - "CLOUDFLARE_ACCOUNT_ID": "", - "READONLY": "true" - } + "$schema": "./node_modules/wrangler/config-schema.json", + "name": "worker-publisher-template", + "main": "./src/index.ts", + "compatibility_date": "2025-10-08", + "upload_source_maps": true, + "dispatch_namespaces": [ + { + "binding": "DISPATCHER", + "namespace": "my-dispatch-namespace", + "remote": true + } + ], + "observability": { + "enabled": true + }, + "vars": { + "CLOUDFLARE_ACCOUNT_ID": "", + "READONLY": "true" + } } diff --git a/workers-builds-notifications-template/wrangler.jsonc b/workers-builds-notifications-template/wrangler.jsonc index 5cf8fe121..83f124af7 100644 --- a/workers-builds-notifications-template/wrangler.jsonc +++ b/workers-builds-notifications-template/wrangler.jsonc @@ -3,30 +3,30 @@ * https://developers.cloudflare.com/workers/wrangler/configuration/ */ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "workers-builds-notifications-template", - "main": "src/index.ts", - "compatibility_date": "2025-10-08", - "upload_source_maps": true, - "observability": { - "enabled": true - }, - "assets": { - "directory": "./public" - }, - /** + "$schema": "node_modules/wrangler/config-schema.json", + "name": "workers-builds-notifications-template", + "main": "src/index.ts", + "compatibility_date": "2025-10-08", + "upload_source_maps": true, + "observability": { + "enabled": true + }, + "assets": { + "directory": "./public" + }, + /** * Queue Consumer Configuration * * IMPORTANT: Update the "queue" value below to match your queue name. */ - "queues": { - "consumers": [ - { - "queue": "builds-event-subscriptions", - "max_batch_size": 10, - "max_batch_timeout": 30, - "max_retries": 3 - } - ] - } + "queues": { + "consumers": [ + { + "queue": "builds-event-subscriptions", + "max_batch_size": 10, + "max_batch_timeout": 30, + "max_retries": 3 + } + ] + } } diff --git a/workers-for-platforms-template/wrangler.jsonc b/workers-for-platforms-template/wrangler.jsonc index 3231ceb1b..04202bc43 100644 --- a/workers-for-platforms-template/wrangler.jsonc +++ b/workers-for-platforms-template/wrangler.jsonc @@ -1,46 +1,48 @@ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "workers-for-platforms-template", - "main": "src/index.ts", - "compatibility_date": "2025-10-08", - "compatibility_flags": ["nodejs_compat"], - // Enable workers.dev subdomain (set to false if using custom domain with routes) - "workers_dev": true, - // Smart Placement - automatically run Worker close to your back-end services - "placement": { - "mode": "smart" - }, - // Observability - enable logging for debugging - "observability": { - "enabled": true - }, - // Workers for Platforms dispatch namespace - // This is the core binding that enables multi-tenant Worker deployment - // The namespace will be auto-created by the setup script - "dispatch_namespaces": [ - { - "binding": "dispatcher", - "namespace": "workers-for-platforms-template", - "remote": true - } - ], - // D1 Database for storing project metadata - // The database will be auto-provisioned during deployment - "d1_databases": [ - { - "binding": "DB", - "database_name": "workers-for-platforms-template", - "database_id": "39f0ae3f-5dbc-4357-aa4d-bc52ce832621" - } - ], - // Environment variables - "vars": { - // Dispatch namespace name - must match the namespace above - "DISPATCH_NAMESPACE_NAME": "workers-for-platforms-template", - // Optional: Your platform's custom domain (e.g., "myplatform.com"). Leave empty to use workers.dev - "CUSTOM_DOMAIN": "" - }, - // Note: FALLBACK_ORIGIN, CLOUDFLARE_ZONE_ID, ACCOUNT_ID, and - // DISPATCH_NAMESPACE_API_TOKEN are auto-configured by the setup script - "upload_source_maps": true + "$schema": "node_modules/wrangler/config-schema.json", + "name": "workers-for-platforms-template", + "main": "src/index.ts", + "compatibility_date": "2025-10-08", + "compatibility_flags": [ + "nodejs_compat" + ], + // Enable workers.dev subdomain (set to false if using custom domain with routes) + "workers_dev": true, + // Smart Placement - automatically run Worker close to your back-end services + "placement": { + "mode": "smart" + }, + // Observability - enable logging for debugging + "observability": { + "enabled": true + }, + // Workers for Platforms dispatch namespace + // This is the core binding that enables multi-tenant Worker deployment + // The namespace will be auto-created by the setup script + "dispatch_namespaces": [ + { + "binding": "dispatcher", + "namespace": "workers-for-platforms-template", + "remote": true + } + ], + // D1 Database for storing project metadata + // The database will be auto-provisioned during deployment + "d1_databases": [ + { + "binding": "DB", + "database_name": "workers-for-platforms-template", + "database_id": "39f0ae3f-5dbc-4357-aa4d-bc52ce832621" + } + ], + // Environment variables + "vars": { + // Dispatch namespace name - must match the namespace above + "DISPATCH_NAMESPACE_NAME": "workers-for-platforms-template", + // Optional: Your platform's custom domain (e.g., "myplatform.com"). Leave empty to use workers.dev + "CUSTOM_DOMAIN": "" + }, + // Note: FALLBACK_ORIGIN, CLOUDFLARE_ZONE_ID, ACCOUNT_ID, and + // DISPATCH_NAMESPACE_API_TOKEN are auto-configured by the setup script + "upload_source_maps": true } diff --git a/workflows-starter-template/wrangler.jsonc b/workflows-starter-template/wrangler.jsonc index b9f214600..2f0072f53 100644 --- a/workflows-starter-template/wrangler.jsonc +++ b/workflows-starter-template/wrangler.jsonc @@ -3,51 +3,53 @@ * https://developers.cloudflare.com/workers/wrangler/configuration/ */ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "workflows-starter-template", - "main": "worker/index.ts", - "compatibility_date": "2025-10-08", - "assets": { - "directory": "./dist", - "not_found_handling": "single-page-application" - }, - "observability": { - "enabled": true - }, - /** + "$schema": "node_modules/wrangler/config-schema.json", + "name": "workflows-starter-template", + "main": "worker/index.ts", + "compatibility_date": "2025-10-08", + "assets": { + "directory": "./dist", + "not_found_handling": "single-page-application" + }, + "observability": { + "enabled": true + }, + /** * Workflows * Define Workflows to orchestrate multi-step processes * https://developers.cloudflare.com/workflows/ */ - "workflows": [ - { - "name": "my-workflow", - "binding": "MY_WORKFLOW", - "class_name": "MyWorkflow" - } - ], - /** + "workflows": [ + { + "name": "my-workflow", + "binding": "MY_WORKFLOW", + "class_name": "MyWorkflow" + } + ], + /** * Durable Objects * Used for WebSocket state management and real-time updates * https://developers.cloudflare.com/durable-objects/ */ - "durable_objects": { - "bindings": [ - { - "name": "WORKFLOW_STATUS", - "class_name": "WorkflowStatusDO" - } - ] - }, - /** + "durable_objects": { + "bindings": [ + { + "name": "WORKFLOW_STATUS", + "class_name": "WorkflowStatusDO" + } + ] + }, + /** * Migrations * Required for Durable Objects */ - "migrations": [ - { - "tag": "v1", - "new_sqlite_classes": ["WorkflowStatusDO"] - } - ], - "upload_source_maps": true + "migrations": [ + { + "tag": "v1", + "new_sqlite_classes": [ + "WorkflowStatusDO" + ] + } + ], + "upload_source_maps": true } diff --git a/x402-proxy-template/wrangler.jsonc b/x402-proxy-template/wrangler.jsonc index bf9d9926a..2dee26442 100644 --- a/x402-proxy-template/wrangler.jsonc +++ b/x402-proxy-template/wrangler.jsonc @@ -5,110 +5,110 @@ * https://developers.cloudflare.com/workers/wrangler/configuration/ */ { - "$schema": "node_modules/wrangler/config-schema.json", - "name": "x402-proxy-template", - "main": "src/index.ts", - "compatibility_date": "2025-10-08", - "observability": { - "enabled": true, - }, - "assets": { - "directory": "public", - }, - // ========================================================================= - // ROUTES - Where x402-proxy intercepts requests - // ========================================================================= - // Uncomment and configure routes to deploy x402-proxy on your domain. - // The proxy will intercept all requests matching these patterns. - // - // "routes": [ - // { - // "pattern": "api.example.com/*", - // "zone_name": "example.com", - // }, - // ], - // ========================================================================= - // SERVICE BINDING - If your origin is another Cloudflare Worker - // ========================================================================= - // Use this instead of ORIGIN_URL when your backend is another Worker - // in your account. Service Bindings are faster (no network hop) and - // don't require the origin Worker to have a public route. - // - // "services": [ - // { - // "binding": "ORIGIN_SERVICE", - // "service": "my-origin-worker", - // }, - // ], - "vars": { - // ===================================================================== - // PAY_TO - Your wallet address to receive payments (REQUIRED) - // ===================================================================== - // This is where payments will be sent when users pay for access. - // Any Ethereum-compatible wallet works (MetaMask, Coinbase Wallet, etc.). - // - // The default "dead address" below is useful for testing - payments - // sent there are unrecoverable but allow testing the flow. - // - "PAY_TO": "0x000000000000000000000000000000000000dEaD", - // ===================================================================== - // NETWORK - Blockchain network for payments (REQUIRED) - // ===================================================================== - // Use "base-sepolia" for testing (free testnet tokens). - // Use "base" for production. - // - // Get testnet tokens: https://docs.cdp.coinbase.com/faucets/ - // Supported networks: https://x402.org - // - "NETWORK": "base-sepolia", - // ===================================================================== - // PROTECTED_PATTERNS - Routes requiring payment (REQUIRED) - // ===================================================================== - // Define which routes require payment and how much they cost. - // Each entry has: - // - pattern: Route to protect (supports /* wildcards) - // - price: Cost in USD (e.g., "$0.01") - // - description: Shown to users explaining what they're paying for - // - // After payment, users get a JWT cookie valid for 1 hour. - // - "PROTECTED_PATTERNS": [ - { - "pattern": "/premium/*", - "price": "$0.01", - "description": "Access to premium content for 1 hour", - }, - ], - // ===================================================================== - // ORIGIN_URL - External origin URL (OPTIONAL) - // ===================================================================== - // Controls how requests are proxied to your backend after authentication. - // - // NOT SET (default): DNS-based proxy mode. Requests are forwarded to the - // origin server defined in your Cloudflare DNS records. Use this when your - // backend is a traditional server (VM, container, etc.). - // - // SET TO A URL: External Origin mode. Requests are rewritten to this URL. - // Use this to proxy to another Cloudflare Worker (on a Custom Domain) or - // any external service. - // - // Note: If ORIGIN_SERVICE binding is configured above, it takes priority - // over both ORIGIN_URL and DNS-based routing. - // - // "ORIGIN_URL": "https://my-backend.example.com", - // ===================================================================== - // FACILITATOR_URL - Payment verification service (OPTIONAL) - // ===================================================================== - // The facilitator verifies and settles payments on behalf of your server. - // Defaults to CDP facilitator if not set. - // - // Example facilitators: - // - CDP (default): https://x402.org/facilitator (Base, Base Sepolia) - // - PayAI: https://facilitator.payai.network (multi-chain) - // - // See: https://x402.gitbook.io/x402/core-concepts/facilitator - // - "FACILITATOR_URL": "https://x402.org/facilitator", - }, - "upload_source_maps": true, + "$schema": "node_modules/wrangler/config-schema.json", + "name": "x402-proxy-template", + "main": "src/index.ts", + "compatibility_date": "2025-10-08", + "observability": { + "enabled": true + }, + "assets": { + "directory": "public" + }, + // ========================================================================= + // ROUTES - Where x402-proxy intercepts requests + // ========================================================================= + // Uncomment and configure routes to deploy x402-proxy on your domain. + // The proxy will intercept all requests matching these patterns. + // + // "routes": [ + // { + // "pattern": "api.example.com/*", + // "zone_name": "example.com", + // }, + // ], + // ========================================================================= + // SERVICE BINDING - If your origin is another Cloudflare Worker + // ========================================================================= + // Use this instead of ORIGIN_URL when your backend is another Worker + // in your account. Service Bindings are faster (no network hop) and + // don't require the origin Worker to have a public route. + // + // "services": [ + // { + // "binding": "ORIGIN_SERVICE", + // "service": "my-origin-worker", + // }, + // ], + "vars": { + // ===================================================================== + // PAY_TO - Your wallet address to receive payments (REQUIRED) + // ===================================================================== + // This is where payments will be sent when users pay for access. + // Any Ethereum-compatible wallet works (MetaMask, Coinbase Wallet, etc.). + // + // The default "dead address" below is useful for testing - payments + // sent there are unrecoverable but allow testing the flow. + // + "PAY_TO": "0x000000000000000000000000000000000000dEaD", + // ===================================================================== + // NETWORK - Blockchain network for payments (REQUIRED) + // ===================================================================== + // Use "base-sepolia" for testing (free testnet tokens). + // Use "base" for production. + // + // Get testnet tokens: https://docs.cdp.coinbase.com/faucets/ + // Supported networks: https://x402.org + // + "NETWORK": "base-sepolia", + // ===================================================================== + // PROTECTED_PATTERNS - Routes requiring payment (REQUIRED) + // ===================================================================== + // Define which routes require payment and how much they cost. + // Each entry has: + // - pattern: Route to protect (supports /* wildcards) + // - price: Cost in USD (e.g., "$0.01") + // - description: Shown to users explaining what they're paying for + // + // After payment, users get a JWT cookie valid for 1 hour. + // + "PROTECTED_PATTERNS": [ + { + "pattern": "/premium/*", + "price": "$0.01", + "description": "Access to premium content for 1 hour" + } + ], + // ===================================================================== + // ORIGIN_URL - External origin URL (OPTIONAL) + // ===================================================================== + // Controls how requests are proxied to your backend after authentication. + // + // NOT SET (default): DNS-based proxy mode. Requests are forwarded to the + // origin server defined in your Cloudflare DNS records. Use this when your + // backend is a traditional server (VM, container, etc.). + // + // SET TO A URL: External Origin mode. Requests are rewritten to this URL. + // Use this to proxy to another Cloudflare Worker (on a Custom Domain) or + // any external service. + // + // Note: If ORIGIN_SERVICE binding is configured above, it takes priority + // over both ORIGIN_URL and DNS-based routing. + // + // "ORIGIN_URL": "https://my-backend.example.com", + // ===================================================================== + // FACILITATOR_URL - Payment verification service (OPTIONAL) + // ===================================================================== + // The facilitator verifies and settles payments on behalf of your server. + // Defaults to CDP facilitator if not set. + // + // Example facilitators: + // - CDP (default): https://x402.org/facilitator (Base, Base Sepolia) + // - PayAI: https://facilitator.payai.network (multi-chain) + // + // See: https://x402.gitbook.io/x402/core-concepts/facilitator + // + "FACILITATOR_URL": "https://x402.org/facilitator" + }, + "upload_source_maps": true }