@bounda-dev/cloudflare
v0.2.4
Published
Cloudflare Durable Objects storage adapter for Bounda
Readme
@bounda-dev/cloudflare
A Bounda store in a Cloudflare Durable Object: the events, the read models and the scheduled work in the object's own SQLite, one object per tenant, and no server or background process to run.
npm create bounda@latest my-app -- --runtime cloudflareOr by hand:
// bounda.config.ts
import { cloudflare } from "@bounda-dev/cloudflare";
import { defineConfig } from "@bounda-dev/core/config";
export default defineConfig({ storage: cloudflare() });// src/worker.ts
import { createBoundaObject, createWorker } from "@bounda-dev/cloudflare";
import { registry } from "../.bounda/registry.ts";
import config from "../bounda.config.ts";
export const Store = createBoundaObject({ registry, config });
export default createWorker({
config,
tenantOf: (request) => request.headers.get("x-bounda-tenant") ?? "default",
});wrangler.jsonc binds STORE to the Store class with a new_sqlite_classes migration.
- A command resolves once its events are stored and every read model reflects them, or, with
consistency: "eventual"inconnectorcreateWorker, once they are stored. - Policies, processes, scheduled commands and retries run in the object's alarm, which it arms itself.
createWorkerservesPOST /commands/<name>andPOST /queries/<name>as JSON, one store per tenant, whichtenantOfnames. It has no authentication: a starting point. Your ownfetchtalks to a store withconnect(stub), which typescommandsandqueriesfrom your modules.- A React Router app runs in the Worker too, through
@bounda-dev/react-router:npm create bounda@latest my-app -- --runtime cloudflare --framework react-router.
Status
0.x. Until 1.0 the API can still change between minor versions, and every change that breaks something is called out in the changelog.
Docs: docs.bounda.dev. Source and issues: github.com/bounda-dev/bounda.
