1
0
Fork 0
mirror of https://github.com/imjasonh/terraform-playground synced 2026-07-09 16:16:57 +00:00
terraform-playground/cf-worker/script.js
Jason Hall f5ae8b5cb2
demo using ESM with KV and R2
Signed-off-by: Jason Hall <jason@chainguard.dev>
2023-08-12 10:40:58 -04:00

16 lines
401 B
JavaScript

export default {
async fetch(request, env, ctx) {
let value = await env.KV.get("foo");
await env.KV.put("foo", value + "r");
let obj = await env.R2.get("foo");
if (!obj) {
obj = "ba";
} else {
obj = await obj.text();
}
await env.R2.put("foo", obj + "r");
return new Response(`${value} / ${obj}`);
},
};