mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
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:
2
examples/cloudflare-worker/.gitignore
vendored
2
examples/cloudflare-worker/.gitignore
vendored
@@ -170,3 +170,5 @@ dist
|
||||
|
||||
.dev.vars
|
||||
.wrangler/
|
||||
bknd-types.d.ts
|
||||
worker-configuration.d.ts
|
||||
12
examples/cloudflare-worker/bknd.config.ts
Normal file
12
examples/cloudflare-worker/bknd.config.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* Optionally wrapping the configuration with the `withPlatformProxy` function
|
||||
* enables programmatic access to the bindings, e.g. for generating types.
|
||||
*/
|
||||
|
||||
import { withPlatformProxy } from "bknd/adapter/cloudflare";
|
||||
|
||||
export default withPlatformProxy({
|
||||
d1: {
|
||||
session: true,
|
||||
},
|
||||
});
|
||||
@@ -2,16 +2,19 @@
|
||||
"name": "cloudflare-worker",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"deploy": "wrangler deploy",
|
||||
"dev": "wrangler dev",
|
||||
"typegen": "wrangler types"
|
||||
"bknd-typegen": "PROXY=1 npx bknd types",
|
||||
"typegen": "wrangler types && npm run bknd-typegen",
|
||||
"predev": "npm run typegen"
|
||||
},
|
||||
"dependencies": {
|
||||
"bknd": "file:../../app"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.8.3",
|
||||
"wrangler": "^4.19.1"
|
||||
"typescript": "^5.9.2",
|
||||
"wrangler": "^4.28.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import { serve } from "bknd/adapter/cloudflare";
|
||||
import config from "../bknd.config";
|
||||
|
||||
export default serve({
|
||||
mode: "warm",
|
||||
d1: {
|
||||
session: true,
|
||||
},
|
||||
});
|
||||
export default serve(config);
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2021",
|
||||
"lib": ["es2021"],
|
||||
"jsx": "react-jsx",
|
||||
"module": "es2022",
|
||||
"moduleResolution": "Bundler",
|
||||
"types": ["./worker-configuration.d.ts"],
|
||||
"lib": ["ES2022"],
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"allowJs": true,
|
||||
"checkJs": false,
|
||||
@@ -18,5 +16,10 @@
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"exclude": ["test"],
|
||||
"include": ["worker-configuration.d.ts", "src/**/*.ts"]
|
||||
"include": [
|
||||
"worker-configuration.d.ts",
|
||||
"bknd-types.d.ts",
|
||||
"bknd.config.ts",
|
||||
"src/**/*.ts"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// placeholder, run generation again
|
||||
declare namespace Cloudflare {
|
||||
interface Env {
|
||||
BUCKET: R2Bucket;
|
||||
DB: D1Database;
|
||||
}
|
||||
}
|
||||
interface Env extends Cloudflare.Env {}
|
||||
Reference in New Issue
Block a user