Skip to content

About

Platform SDK for bext — mirror of packages/bext-platform

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

@bext-stack/platform

Typed platform SDK for bext apps. Provides KV, queue, cache, realtime, scheduler, secrets, database, and blob storage clients that talk to the bext runtime over HTTP.

Install

npm i @bext-stack/platform

Usage

import { createClient } from "@bext-stack/platform";

const bext = createClient();

// KV
await bext.kv.set("user:1", { name: "Ben" }, { ttlSeconds: 3600 });
const user = await bext.kv.get<{ name: string }>("user:1");

// Queue
await bext.queue.push("jobs", { type: "email", to: "a@b.com" });
const messages = await bext.queue.pull("jobs", { batch: 10 });
for (const m of messages) {
  await bext.queue.ack("jobs", m.id);
}

// Cache with tag invalidation
await bext.cache.set("posts:index", posts, { tags: ["posts"] });
await bext.cache.invalidate({ tags: ["posts"] });

// Realtime
await bext.realtime.publish("chat:room-1", { text: "hello" });

// Scheduler
await bext.scheduler.register({
  name: "nightly-cleanup",
  cron: "0 3 * * *",
  handler: "/jobs/cleanup",
});

// Secrets
await bext.secrets.set("STRIPE_KEY", "sk_live_...");

// Database
const rows = await bext.db.query("SELECT * FROM users WHERE id = ?", [42]);

// Blob
await bext.blob.put("uploads/hello.txt", "hello world", "text/plain");

Config

createClient({
  baseUrl: "http://localhost:3062", // default: same-origin
  apiKey: process.env.BEXT_API_KEY,  // optional
  authHeader: "X-Bext-Key",          // default header name
});

How it works

Every method is a thin HTTP call to the /__bext/sdk/* endpoints exposed by bext-server. Your app code talks to localhost:3062 (or whatever baseUrl you configure), and bext handles persistence, replication, and cache coherency under the hood.

License

MIT — Part of the bext stack.

About

Platform SDK for bext — mirror of packages/bext-platform

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages