adding d1 session support

This commit is contained in:
dswbx
2025-06-06 11:13:35 +02:00
parent 3e77982996
commit 6ee898e606
17 changed files with 5914 additions and 57 deletions

View File

@@ -1,10 +1,15 @@
/// <reference types="@cloudflare/workers-types" />
import { serve } from "bknd/adapter/cloudflare";
import { type D1Connection, serve } from "bknd/adapter/cloudflare";
export default serve({
mode: "warm",
d1: {
session: true,
},
onBuilt: async (app) => {
app.modules.server.get("/custom", (c) => c.json({ hello: "world" }));
app.modules.server.get("/custom", async (c) => {
const conn = c.var.app.em.connection as D1Connection;
const res = await conn.client.prepare("select * from __bknd limit 1").all();
return c.json({ hello: "world", res });
});
},
});