diff --git a/.github/workflows/pr_checks.yml b/.github/workflows/pr_checks.yml index 56a46c3..51804df 100644 --- a/.github/workflows/pr_checks.yml +++ b/.github/workflows/pr_checks.yml @@ -24,7 +24,7 @@ jobs: - name: Clippy for API run: cargo clippy --package api - clippy-webapp: + clippy-webapp-yew: runs-on: ubuntu-latest steps: @@ -36,7 +36,21 @@ jobs: toolchain: stable - name: Clippy for Webapp - run: cargo clippy --package webapp + run: cargo clippy --package yew_csr + + clippy-webapp-axum: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + + - name: Clippy for Webapp + run: cargo clippy --package axum_htmx build-api: runs-on: ubuntu-latest @@ -52,7 +66,7 @@ jobs: - name: Build API run: cargo build --package api - build-webapp: + build-webapp-yew: runs-on: ubuntu-latest steps: @@ -75,9 +89,23 @@ jobs: crate: wasm-bindgen-cli - name: Build Webapp - working-directory: ./webapp + working-directory: ./webapp/yew_csr run: trunk build + build-webapp-axum: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + + - name: Build Webapp + run: cargo build --package axum_htmx + test-api: runs-on: ubuntu-latest @@ -92,7 +120,7 @@ jobs: - name: Test API run: cargo test --package api - test-webapp: + test-webapp-yew: runs-on: ubuntu-latest steps: @@ -114,5 +142,18 @@ jobs: crate: wasm-bindgen-cli - name: Test Webapp - working-directory: ./webapp - run: cargo test --package webapp + run: cargo test --package yew_csr + + test-webapp-axum: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + + - name: Test Webapp + run: cargo test --package axum_htmx diff --git a/Cargo.lock b/Cargo.lock index e1cb30c..d4f03e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -56,6 +56,7 @@ checksum = "1236b4b292f6c4d6dc34604bb5120d85c3fe1d1aa596bd5cc52ca054d13e7b9e" dependencies = [ "async-trait", "axum-core", + "base64", "bytes", "futures-util", "http 1.0.0", @@ -74,8 +75,10 @@ dependencies = [ "serde_json", "serde_path_to_error", "serde_urlencoded", + "sha1", "sync_wrapper", "tokio", + "tokio-tungstenite", "tower", "tower-layer", "tower-service", @@ -103,6 +106,13 @@ dependencies = [ "tracing", ] +[[package]] +name = "axum_htmx" +version = "0.1.0" +dependencies = [ + "axum", +] + [[package]] name = "backtrace" version = "0.3.69" @@ -118,6 +128,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + [[package]] name = "bincode" version = "1.3.3" @@ -133,6 +149,15 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + [[package]] name = "boolinator" version = "2.4.0" @@ -145,6 +170,12 @@ version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "bytes" version = "1.5.0" @@ -176,6 +207,41 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "data-encoding" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -274,6 +340,16 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.12" @@ -765,6 +841,16 @@ dependencies = [ "tracing", ] +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "implicit-clone" version = "0.4.8" @@ -967,6 +1053,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "prettyplease" version = "0.2.16" @@ -1046,6 +1138,36 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + [[package]] name = "redox_syscall" version = "0.4.1" @@ -1154,6 +1276,17 @@ dependencies = [ "serde", ] +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -1235,6 +1368,21 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.35.1" @@ -1276,6 +1424,18 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite", +] + [[package]] name = "tokio-util" version = "0.7.10" @@ -1367,12 +1527,69 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.0.0", + "httparse", + "log", + "rand", + "sha1", + "thiserror", + "url", + "utf-8", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-bidi" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + [[package]] name = "version_check" version = "0.9.4" @@ -1461,13 +1678,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webapp" -version = "0.1.0" -dependencies = [ - "yew", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -1582,3 +1792,10 @@ dependencies = [ "quote", "syn 2.0.48", ] + +[[package]] +name = "yew_csr" +version = "0.1.0" +dependencies = [ + "yew", +] diff --git a/Cargo.toml b/Cargo.toml index f4ba346..946945c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ resolver = "2" # We will have a user facing web app and a backend API. However more services may be added in the future. members = [ - "webapp", + "webapp/axum_htmx", + "webapp/yew_csr", "api", -] \ No newline at end of file +] diff --git a/webapp/axum_htmx/Cargo.toml b/webapp/axum_htmx/Cargo.toml new file mode 100644 index 0000000..4b32966 --- /dev/null +++ b/webapp/axum_htmx/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "axum_htmx" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +axum = { version = "0.7.4", features = ["ws"] } diff --git a/webapp/axum_htmx/src/main.rs b/webapp/axum_htmx/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/webapp/axum_htmx/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/webapp/src/app.rs b/webapp/src/app.rs deleted file mode 100644 index db958de..0000000 --- a/webapp/src/app.rs +++ /dev/null @@ -1,14 +0,0 @@ -use yew::prelude::*; - -#[function_component(App)] -pub fn app() -> Html { - // to test lints create an option and use unwrap - - html! { -
- -

{ "Hello World!" }

- { "from Yew with " } -
- } -} diff --git a/webapp/.gitignore b/webapp/yew_csr/.gitignore similarity index 100% rename from webapp/.gitignore rename to webapp/yew_csr/.gitignore diff --git a/webapp/Cargo.lock b/webapp/yew_csr/Cargo.lock similarity index 100% rename from webapp/Cargo.lock rename to webapp/yew_csr/Cargo.lock diff --git a/webapp/Cargo.toml b/webapp/yew_csr/Cargo.toml similarity index 92% rename from webapp/Cargo.toml rename to webapp/yew_csr/Cargo.toml index 084af17..23619c8 100644 --- a/webapp/Cargo.toml +++ b/webapp/yew_csr/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "webapp" +name = "yew_csr" version = "0.1.0" edition = "2021" diff --git a/webapp/Makefile.toml b/webapp/yew_csr/Makefile.toml similarity index 100% rename from webapp/Makefile.toml rename to webapp/yew_csr/Makefile.toml diff --git a/webapp/index.html b/webapp/yew_csr/index.html similarity index 100% rename from webapp/index.html rename to webapp/yew_csr/index.html diff --git a/webapp/index.scss b/webapp/yew_csr/index.scss similarity index 100% rename from webapp/index.scss rename to webapp/yew_csr/index.scss diff --git a/webapp/yew_csr/src/app.rs b/webapp/yew_csr/src/app.rs new file mode 100644 index 0000000..b442fa5 --- /dev/null +++ b/webapp/yew_csr/src/app.rs @@ -0,0 +1,14 @@ +use yew::prelude::*; + +#[function_component(App)] +pub fn app() -> Html { + // this is a htmx project. + // Start the page blank with a button that does a htmx-get to /hello + + html! { +
+ +
+
+ } +} diff --git a/webapp/src/main.rs b/webapp/yew_csr/src/main.rs similarity index 100% rename from webapp/src/main.rs rename to webapp/yew_csr/src/main.rs