mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
adding d1 session support
This commit is contained in:
@@ -9,11 +9,10 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"bknd": "file:../../app",
|
||||
"kysely-d1": "^0.3.0"
|
||||
"kysely-d1": "^0.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/workers-types": "^4.20240620.0",
|
||||
"typescript": "^5.5.3",
|
||||
"wrangler": "^4.4.0"
|
||||
"typescript": "^5.8.3",
|
||||
"wrangler": "^4.19.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"jsx": "react-jsx",
|
||||
"module": "es2022",
|
||||
"moduleResolution": "Bundler",
|
||||
"types": ["@cloudflare/workers-types/2023-07-01"],
|
||||
"types": ["./worker-configuration.d.ts"],
|
||||
"resolveJsonModule": true,
|
||||
"allowJs": true,
|
||||
"checkJs": false,
|
||||
|
||||
5760
examples/cloudflare-worker/worker-configuration.d.ts
vendored
5760
examples/cloudflare-worker/worker-configuration.d.ts
vendored
File diff suppressed because it is too large
Load Diff
@@ -15,8 +15,8 @@
|
||||
"d1_databases": [
|
||||
{
|
||||
"binding": "DB",
|
||||
"database_name": "bknd-cf-example",
|
||||
"database_id": "7ad67953-2bbf-47fc-8696-f4517dbfe674"
|
||||
"database_name": "bknd-dev-weur",
|
||||
"database_id": "81d8dfcc-4eaf-4453-8f0f-8f6d463fb867"
|
||||
}
|
||||
],
|
||||
"r2_buckets": [
|
||||
|
||||
Reference in New Issue
Block a user