35 lines
960 B
Rust
35 lines
960 B
Rust
use functions::deno_runtime::DenoRuntime;
|
|
use std::collections::HashMap;
|
|
use serde_json::json;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
tracing_subscriber::fmt::init();
|
|
|
|
let runtime = DenoRuntime::new();
|
|
let code = r#"
|
|
Deno.serve((req) => {
|
|
return new Response("Hello from reproduction!");
|
|
});
|
|
"#.to_string();
|
|
|
|
let payload = Some(json!({"test": "data"}));
|
|
let headers = HashMap::new();
|
|
|
|
let env_vars = HashMap::new();
|
|
|
|
println!("Starting execution...");
|
|
match runtime.execute(code, payload, headers, env_vars).await {
|
|
Ok((stdout, stderr, status, res_headers, logs)) => {
|
|
println!("Success!");
|
|
println!("Status: {}", status);
|
|
println!("Stdout: {}", stdout);
|
|
println!("Stderr: {}", stderr);
|
|
println!("Headers: {:?}", res_headers);
|
|
},
|
|
Err(e) => {
|
|
eprintln!("Error: {:?}", e);
|
|
}
|
|
}
|
|
}
|