adapter(cloudflare): removed durable mode, added withPlatformProxy (#233)

* removed `durable` mode as it requires an import from "cloudflare:" that often fails in non-cf environments

* remove worker configuration types

* add `withPlatformProxy`

* withPlatformProxy: make configuration optional
This commit is contained in:
dswbx
2025-08-12 15:29:09 +02:00
committed by GitHub
parent b5b4c5eef0
commit 375d2c205f
21 changed files with 152 additions and 197 deletions

View File

@@ -5,8 +5,7 @@ import { Hono } from "hono";
import { serveStatic } from "hono/cloudflare-workers";
import { getFresh } from "./modes/fresh";
import { getCached } from "./modes/cached";
import { getDurable } from "./modes/durable";
import type { App } from "bknd";
import type { App, MaybePromise } from "bknd";
import { $console } from "core/utils";
declare global {
@@ -17,12 +16,11 @@ declare global {
export type CloudflareEnv = Cloudflare.Env;
export type CloudflareBkndConfig<Env = CloudflareEnv> = RuntimeBkndConfig<Env> & {
mode?: "warm" | "fresh" | "cache" | "durable";
bindings?: (args: Env) => {
mode?: "warm" | "fresh" | "cache";
bindings?: (args: Env) => MaybePromise<{
kv?: KVNamespace;
dobj?: DurableObjectNamespace;
db?: D1Database;
};
}>;
d1?: {
session?: boolean;
transport?: "header" | "cookie";
@@ -93,8 +91,6 @@ export function serve<Env extends CloudflareEnv = CloudflareEnv>(
case "cache":
app = await getCached(config, context);
break;
case "durable":
return await getDurable(config, context);
default:
throw new Error(`Unknown mode ${mode}`);
}