Skip to content

Commit b568421

Browse files
committed
thomasgauvin: nits
1 parent c29f156 commit b568421

File tree

1 file changed

+44
-45
lines changed

1 file changed

+44
-45
lines changed

src/content/docs/kv/index.mdx

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -39,53 +39,52 @@ Access your Workers KV namespace from Cloudflare Workers using [Workers Bindings
3939
<TabItem label="Workers Binding API">
4040
<Tabs>
4141
<TabItem label="index.ts">
42-
```ts
43-
export default {
44-
async fetch(request, env, ctx): Promise<Response> {
45-
46-
// write a key-value pair
47-
await env.KV_BINDING.put('KEY', 'VALUE');
48-
49-
// read a key-value pair
50-
const value = await env.KV_BINDING.get('KEY');
51-
52-
// list all key-value pairs
53-
const allKeys = await env.KV_BINDING.list();
54-
55-
// delete a key-value pair
56-
await env.KV_BINDING.delete('KEY');
57-
58-
// return a Workers response
59-
return new Response(
60-
JSON.stringify({
61-
value: value,
62-
allKeys: allKeys,
63-
}),
64-
);
65-
},
66-
};
67-
68-
```
42+
```ts
43+
export default {
44+
async fetch(request, env, ctx): Promise<Response> {
45+
// write a key-value pair
46+
await env.KV_BINDING.put('KEY', 'VALUE');
47+
48+
// read a key-value pair
49+
const value = await env.KV_BINDING.get('KEY');
50+
51+
// list all key-value pairs
52+
const allKeys = await env.KV_BINDING.list();
53+
54+
// delete a key-value pair
55+
await env.KV_BINDING.delete('KEY');
56+
57+
// return a Workers response
58+
return new Response(
59+
JSON.stringify({
60+
value: value,
61+
allKeys: allKeys,
62+
}),
63+
);
64+
},
65+
} satisfies ExportedHandler<{ KV_BINDING: KVNamespace }>;
66+
67+
```
6968
</TabItem>
7069
<TabItem label="wrangler.jsonc">
71-
```json
72-
{
73-
"$schema": "node_modules/wrangler/config-schema.json",
74-
"name": "WORKER-NAME",
75-
"main": "src/index.ts",
76-
"compatibility_date": "2025-02-04",
77-
"observability": {
78-
"enabled": true
79-
},
80-
81-
"kv_namespaces": [
82-
{
83-
"binding": "YOUR_BINDING",
84-
"id": "<YOUR_BINDING_ID>"
85-
}
86-
]
87-
}
88-
```
70+
```json
71+
{
72+
"$schema": "node_modules/wrangler/config-schema.json",
73+
"name": "WORKER-NAME",
74+
"main": "src/index.ts",
75+
"compatibility_date": "2025-02-04",
76+
"observability": {
77+
"enabled": true
78+
},
79+
80+
"kv_namespaces": [
81+
{
82+
"binding": "KV_BINDING",
83+
"id": "<YOUR_BINDING_ID>"
84+
}
85+
]
86+
}
87+
```
8988
</TabItem>
9089
</Tabs>
9190

0 commit comments

Comments
 (0)