https://github.com/ysm-dev/deno_kv_http
🦕 Deno KV HTTP wrapper.
https://github.com/ysm-dev/deno_kv_http
Last synced: 11 months ago
JSON representation
🦕 Deno KV HTTP wrapper.
- Host: GitHub
- URL: https://github.com/ysm-dev/deno_kv_http
- Owner: ysm-dev
- License: mit
- Created: 2023-08-20T03:00:43.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-20T15:40:31.000Z (almost 3 years ago)
- Last Synced: 2025-06-21T02:39:51.243Z (about 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# deno_kv_http
A simple HTTP wrapper for [Deno KV](https://deno.land/manual@v1.36.1/runtime/kv) which you can use in other runtime (e.g. 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.
```ts
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.
```sh
pnpm install deno-kv-http
```
```ts
import { DenoKvHttp } from "deno-kv-http";
const URL = "https://your-project.deno.dev";
const kv = HttpDenoKv(URL);
```
```ts
await kv.set(["foo", 1n, crypto.randomUUID()], crypto.randomUUID());
await kv.set(["foo", 2n], "foo2");
const r2 = await kv.get(["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.