1
2
3
4
5
6
7
8
9
10
11
12
13
14
import createPlugin from "https://esm.sh/@extism/extism";
export default async function(req: Request): Promise<Response> {
const plugin = await createPlugin(
"https://cdn.modsurfer.dylibso.com/api/v1/module/ec17c9afde08aa9e7fa857fe2c9cbb9206e3a3dbec98429ceebd3421de7070da.wasm",
{ useWasi: false },
);
const data = {
event_file_name: "input.md",
event_file_data: btoa(await req.text()),
};
let out = await plugin.call("on_file_write", JSON.stringify(data));
return Response.json(out.json());
}
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.