Skip to content

Commit

Permalink
mored some more helpers to fastn-wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Dec 22, 2024
1 parent 7803121 commit da6a32e
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 47 deletions.
9 changes: 6 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions fastn-ds/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ async-lock.workspace = true
http.workspace = true
bytes.workspace = true
camino.workspace = true
chrono.workspace = true
libsqlite3-sys.workspace = true
futures-util.workspace = true
magic-crypt.workspace = true
async-trait.workspace = true
tokio-postgres.workspace = true
ignore.workspace = true
rand.workspace = true
dirs.workspace = true
tracing.workspace = true
rusqlite.workspace = true
Expand Down
2 changes: 0 additions & 2 deletions fastn-ds/src/wasm/exports/http/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
mod get_request;
mod send_request;
mod send_response;

pub use get_request::get_request;
pub use send_request::send_request;
pub use send_response::send_response;
4 changes: 0 additions & 4 deletions fastn-ds/src/wasm/exports/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
mod aws;
mod crypto;
mod ds;
mod env;
mod http;
mod pg;
mod register;
Expand Down
43 changes: 10 additions & 33 deletions fastn-ds/src/wasm/exports/register.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
impl fastn_ds::wasm::Store {
pub fn register_functions(&self, linker: &mut wasmtime::Linker<fastn_ds::wasm::Store>) {
// general utility functions
fastn_ds::func2!(linker, "env_print", fastn_ds::wasm::exports::env::print);
fastn_ds::func0ret!(linker, "env_now", fastn_ds::wasm::exports::env::now);
fastn_ds::func2ret!(linker, "env_var", fastn_ds::wasm::exports::env::var);
fastn_ds::func0ret!(linker, "env_random", fastn_ds::wasm::exports::env::random);
fastn_ds::func2!(linker, "env_print", fastn_wasm::env::print);
fastn_ds::func0ret!(linker, "env_now", fastn_wasm::env::now);
fastn_ds::func2ret!(linker, "env_var", fastn_wasm::env::var);
fastn_ds::func0ret!(linker, "env_random", fastn_wasm::env::random);

// cryptography related stuff
fastn_ds::func2ret!(
linker,
"crypto_encrypt",
fastn_ds::wasm::exports::crypto::encrypt
);
fastn_ds::func2ret!(
linker,
"crypto_decrypt",
fastn_ds::wasm::exports::crypto::decrypt
);
fastn_ds::func2ret!(linker, "crypto_encrypt", fastn_wasm::crypto::encrypt);
fastn_ds::func2ret!(linker, "crypto_decrypt", fastn_wasm::crypto::decrypt);

// sqlite
fastn_ds::func2ret!(
Expand Down Expand Up @@ -57,37 +49,22 @@ impl fastn_ds::wasm::Store {
"http_get_request",
fastn_ds::wasm::exports::http::get_request
);

fastn_ds::func2ret!(
linker,
"http_send_request",
fastn_ds::wasm::exports::http::send_request
);

fastn_ds::func2ret!(linker, "http_send_request", fastn_wasm::send_request);
fastn_ds::func2!(
linker,
"http_send_response",
fastn_ds::wasm::exports::http::send_response
);

// document store related
fastn_ds::func2ret!(
linker,
"hostn_tejar_write",
fastn_ds::wasm::exports::ds::tejar_write
);

fastn_ds::func2ret!(
linker,
"hostn_tejar_read",
fastn_ds::wasm::exports::ds::tejar_read
);
fastn_ds::func2ret!(linker, "hostn_tejar_write", fastn_wasm::ds::tejar_write);
fastn_ds::func2ret!(linker, "hostn_tejar_read", fastn_wasm::ds::tejar_read);

// aws
fastn_ds::func2ret!(
linker,
"hostn_aws_pre_signed_request",
fastn_ds::wasm::exports::aws::pre_signed_request
fastn_wasm::aws::pre_signed_request
);
}
}
8 changes: 7 additions & 1 deletion v0.5/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,26 @@ async-trait = "0.1"
fastn-builtins = { path = "../fastn-builtins" }
fastn-compiler = { path = "fastn-compiler" }
fastn-continuation = { path = "fastn-continuation" }
fastn-resolved = { path = "../fastn-resolved" }
fastn-package = { path = "fastn-package" }
fastn-resolved = { path = "../fastn-resolved" }
fastn-router = { path = "fastn-router" }
fastn-runtime = { path = "../fastn-runtime" }
fastn-section = { path = "fastn-section" }
fastn-unresolved = { path = "fastn-unresolved" }
ft-sys-shared = "0.1.4"
http = "1"
http-body-util = "0.1"
hyper = { version = "1.5.1", features = ["server", "http1"] }
hyper-util = { version = "0.1.10", features = ["tokio"] }
id-arena = "2"
indexmap = "2"
rand = "0.8"
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
string-interner = "0.18"
tokio = { version = "1", features = ["macros", "rt-multi-thread", "fs"] }
wasmtime = "28"
chrono = { version = "0.4", features = ["serde"] }
magic-crypt = { version = "4", default-features = false }

8 changes: 7 additions & 1 deletion v0.5/fastn-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ homepage.workspace = true
[dependencies]
wasmtime.workspace = true
serde_json.workspace = true
serde.workspace = true
serde.workspace = true
ft-sys-shared.workspace = true
rand.workspace = true
http.workspace = true
reqwest.workspace = true
chrono.workspace = true
magic-crypt.workspace = true
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions v0.5/fastn-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@

extern crate self as fastn_wasm;

pub mod aws;
pub mod crypto;
pub mod ds;
pub mod env;
pub mod helpers;
pub mod send_request;

pub use send_request::send_request;
File renamed without changes.

0 comments on commit da6a32e

Please sign in to comment.