Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: WebAssembly.Instance(): Import #38 module="./snippets/biscuit-auth-28174a22100bb465/inline0.js" #45

Open
gembleman opened this issue Feb 5, 2024 · 0 comments

Comments

@gembleman
Copy link

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(),
    })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant