Roshan P 06214d9cba
Add worker-kv crate to repository. (#494)
* Initially adding files.

* Move examples, add to cargo build.

* remove files

* Fix KV paths and link dependencies to workspace.

* Add test package to cargo.lock

* Update kv test dependencies.

* Add send/sync to KvStore.

* Remove dead code.

* Fix cargo.lock

* Undo cargo.lock changes.

* Fix formatting.

* Make code idiomatic.
2024-03-27 17:56:18 -04:00

28 lines
574 B
JavaScript

addEventListener("fetch", (event) => {
event.respondWith(handleRequest(event.request));
});
/**
* Fetch and log a request
* @param {Request} request
*/
async function handleRequest() {
const { start } = wasm_bindgen;
await wasm_bindgen(wasm);
try {
const text = await start();
return new Response(text, {
status: 200,
headers: {
"Content-type": "application/json",
},
});
} catch (error) {
return new Response(error, {
status: 500,
});
}
}