update index.js from universal lambda project
All checks were successful
Generic zig build / build (push) Successful in 26s

This commit is contained in:
Emil Lerch 2024-05-06 11:27:11 -07:00
parent 68e6e14bea
commit e8b0ff50fe
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -1,4 +1,4 @@
import demoWasm from "demo.wasm"; import customWasm from "custom.wasm";
export default { export default {
async fetch(request, _env2, ctx) { async fetch(request, _env2, ctx) {
const stdout = new TransformStream(); const stdout = new TransformStream();
@ -11,7 +11,7 @@ export default {
}); });
const wasi = new WASI({ const wasi = new WASI({
args: [ args: [
"./demo.wasm", "./custom.wasm",
// In a CLI, the first arg is the name of the exe // In a CLI, the first arg is the name of the exe
"--url=" + request.url, "--url=" + request.url,
// this contains the target but is the full url, so we will use a different arg for this // this contains the target but is the full url, so we will use a different arg for this
@ -22,7 +22,7 @@ export default {
stdin: request.body, stdin: request.body,
stdout: stdout.writable stdout: stdout.writable
}); });
const instance = new WebAssembly.Instance(demoWasm, { const instance = new WebAssembly.Instance(customWasm, {
wasi_snapshot_preview1: wasi.wasiImport wasi_snapshot_preview1: wasi.wasiImport
}); });
ctx.waitUntil(wasi.start(instance)); ctx.waitUntil(wasi.start(instance));