Open
Description
Uncaught TypeError: WebAssembly.Instance(): Import #38 module="./snippets/biscuit-auth-28174a22100bb465/inline0.js": module is not an object or function
I thought it would be cool to use worker-rs and biscuit together, so I tried it.
However, this error appears. Can you help me?
I tried with template file for worker-rs was obtained from here.
https://github.com/cloudflare/workers-rs/tree/main/examples/router
Cargo.toml
[package]
name = "router-on-workers"
version = "0.1.0"
edition = "2021"
# https://github.com/rustwasm/wasm-pack/issues/1247
[package.metadata.wasm-pack.profile.release]
wasm-opt = false
[lib]
crate-type = ["cdylib"]
[dependencies]
serde = "1.0.188"
worker = "0.0.18"
biscuit-wasm = "0.1.3"
[dev-dependencies]
tokio = { version = "1", features = ["full"] }
lib.rs
use biscuit_wasm::*;
use serde::{Deserialize, Serialize};
use worker::*;
#[derive(Debug, Deserialize, Serialize)]
struct GenericResponse {
status: u16,
message: String,
}
#[event(fetch)]
async fn main(req: Request, env: Env, _ctx: Context) -> Result<Response> {
let key = KeyPair::new();
Router::new()
.get_async("/foo", handle_get)
.post_async("/bar", handle_post)
.delete_async("/baz", handle_delete)
.run(req, env)
.await
}
pub async fn handle_get(_: Request, _ctx: RouteContext<()>) -> worker::Result<Response> {
Response::from_json(&GenericResponse {
status: 200,
message: "You reached a GET route!".to_string(),
})
}
pub async fn handle_post(_: Request, _ctx: RouteContext<()>) -> worker::Result<Response> {
Response::from_json(&GenericResponse {
status: 200,
message: "You reached a POST route!".to_string(),
})
}
pub async fn handle_delete(_: Request, _ctx: RouteContext<()>) -> worker::Result<Response> {
Response::from_json(&GenericResponse {
status: 200,
message: "You reached a DELETE route!".to_string(),
})
}
Metadata
Metadata
Assignees
Labels
No labels