deno-kv-http
v0.0.3
Published
Deno KV HTTP wrapper.
Downloads
3
Readme
deno_kv_http
A Deno KV HTTP wrapper library that allows you to use the Deno KV interface as-is across multiple runtimes.
Supports: Node.js, Browser, Vercel Edge runtime, Cloudflare Workers.
Usage
Create new Deno Deploy project: https://dash.deno.com/new
Select
Hello World
-Try with playground
- Copy & Paste this code to Deno Deploy editor.
import { HttpDenoKv } from "https://deno.land/x/deno_kv_http/mod.ts";
Deno.serve((req: Request) => HttpDenoKv(req));
- Click ▶︎ Save & Deploy button.
Copy your Deno Deploy URL. (e.g.
https://your-project.deno.dev
)Install
deno-kv-http
to your project.
pnpm install deno-kv-http
// Node.js, Vercel Edge runtime, Cloudflare Workers
import { DenoKvHttp } from "deno-kv-http";
const URL = "https://your-project.deno.dev";
const kv = HttpDenoKv(URL);
API
Same as Deno KV API.
await kv.set(["foo", 1n, crypto.randomUUID()], crypto.randomUUID());
await kv.set(["foo", 2n], "foo2");
const r2 = await kv.get<string>(["foo", 1n]);
await kv.delete(["foo"]);
const r4 = await kv.get(["foo"]);
const iter = kv.list({ prefix: ["foo"] }, { limit: 100 });
for await (const entry of iter) {
console.log(entry);
}
const r = await kv.getMany([
["foo", 1n],
["foo", 2n],
]);
kv.atomic()
,kv.close()
not supported yet.