added r2 binding support to cf adapter

This commit is contained in:
dswbx
2025-02-11 10:04:53 +01:00
parent be39d1c374
commit 7a6321f4ce
12 changed files with 157 additions and 61 deletions

View File

@@ -1,6 +1,6 @@
import { App } from "bknd";
import { createRuntimeApp } from "bknd/adapter";
import type { CloudflareBkndConfig, Context } from "../index";
import { type CloudflareBkndConfig, type Context, makeCfConfig } from "../index";
export async function getCached(config: CloudflareBkndConfig, { env, ctx, ...args }: Context) {
const { kv } = config.bindings?.(env)!;
@@ -16,7 +16,7 @@ export async function getCached(config: CloudflareBkndConfig, { env, ctx, ...arg
const app = await createRuntimeApp(
{
...config,
...makeCfConfig(config, { env, ctx, ...args }),
initialConfig,
onBuilt: async (app) => {
app.module.server.client.get("/__bknd/cache", async (c) => {

View File

@@ -1,11 +1,11 @@
import type { App } from "bknd";
import { createRuntimeApp } from "bknd/adapter";
import type { CloudflareBkndConfig, Context } from "../index";
import { type CloudflareBkndConfig, type Context, makeCfConfig } from "../index";
export async function makeApp(config: CloudflareBkndConfig, ctx: Context) {
return await createRuntimeApp(
{
...config,
...makeCfConfig(config, ctx),
adminOptions: config.html ? { html: config.html } : undefined
},
ctx