Skip to content

Commit

Permalink
feat: kv
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRohit committed Sep 2, 2024
1 parent 1e5b7a1 commit fcb71f9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
14 changes: 13 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import { Hono } from "hono";
import type { KVNamespace } from "@cloudflare/workers-types";

const app = new Hono();
type Bindings = {
KV: KVNamespace;
};

const app = new Hono<{ Bindings: Bindings }>();

app.get("/", (c) => {
return c.text("Hello , the deploy works!");
});

app.put("/add/:key", async (c) => {
const key = c.req.param("key");
const body = await c.req.text();
await c.env.KV.put(key, body);
return c.text(`Put ${key} successfully!`);
});

export default app;
12 changes: 6 additions & 6 deletions wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ minify = true
# [vars]
# MY_VAR = "my-variable"

# [[kv_namespaces]]
# binding = "KV"
# id = "13450004194144c38ef264d360dbc498"
[[kv_namespaces]]
binding = "KV"
id = "13450004194144c38ef264d360dbc498"

# [[r2_buckets]]
# binding = "R2"
# bucket_name = "hono-r2-bucket"
[[r2_buckets]]
binding = "R2"
bucket_name = "hono-r2-bucket"

[[d1_databases]]
binding = "DB"
Expand Down

0 comments on commit fcb71f9

Please sign in to comment.