From 3e9a042444d2fac4747b8e32f641bae6fd28b7f1 Mon Sep 17 00:00:00 2001 From: spinline Date: Wed, 11 Feb 2026 22:15:33 +0300 Subject: [PATCH] fix(setup): align dependencies to Axum 0.8 and fix server function handler trait bounds --- Cargo.lock | 196 +++++++++++++++++++++++++++++++++++++++----- backend/Cargo.toml | 9 +- backend/src/main.rs | 51 ++++++------ shared/Cargo.toml | 5 +- 4 files changed, 207 insertions(+), 54 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index efa2514..309b2ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -323,6 +323,7 @@ dependencies = [ "jsonwebtoken", "leptos", "leptos_axum", + "leptos_router", "mime_guess", "openssl", "quick-xml", @@ -520,9 +521,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.57" +version = "4.5.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6899ea499e3fb9305a65d5ebf6e3d2248c5fab291f300ad0a704fbe142eae31a" +checksum = "63be97961acde393029492ce0be7a1af7e323e6bae9511ebfac33751be5e6806" dependencies = [ "clap_builder", "clap_derive", @@ -530,9 +531,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.57" +version = "4.5.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b12c8b680195a62a8364d16b8447b01b6c2c8f9aaf68bee653be34d4245e238" +checksum = "7f13174bda5dfd69d7e947827e5af4b0f2f94a4a3ee92912fba07a66150f21e2" dependencies = [ "anstream", "anstyle", @@ -554,9 +555,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.7" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32" +checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" [[package]] name = "coarsetime" @@ -940,9 +941,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.5.5" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" +checksum = "cc3dc5ad92c2e2d1c193bbbbdf2ea477cb81331de4f3103f267ca18368b988c4" dependencies = [ "powerfmt", "serde_core", @@ -1426,6 +1427,19 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", + "wasip3", +] + [[package]] name = "gloo-console" version = "0.3.0" @@ -1634,9 +1648,9 @@ dependencies = [ [[package]] name = "hmac-sha512" -version = "1.1.10" +version = "1.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "425aae4cbcd7250fdcc9665de9cbec21348dd4b6c6a7321b2f5eaf41a3e97dcd" +checksum = "5075d41b75a022af043a5bbf49b89abf17665d5aebf6f6ec64ffff207d87654d" dependencies = [ "digest", ] @@ -1945,6 +1959,12 @@ dependencies = [ "zerovec", ] +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + [[package]] name = "ident_case" version = "1.0.1" @@ -2113,6 +2133,12 @@ dependencies = [ "spin", ] +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + [[package]] name = "leptos" version = "0.8.15" @@ -2373,9 +2399,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.180" +version = "0.2.181" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" +checksum = "459427e2af2b9c839b132acb702a1c654d95e10f8c326bfc2ad11310e458b1c5" [[package]] name = "libm" @@ -2391,7 +2417,7 @@ checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616" dependencies = [ "bitflags", "libc", - "redox_syscall 0.7.0", + "redox_syscall 0.7.1", ] [[package]] @@ -3250,9 +3276,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f3fe0889e69e2ae9e41f4d6c4c0181701d00e4697b356fb1f74173a5e0ee27" +checksum = "35985aa610addc02e24fc232012c86fd11f14111180f902b67e2d5331f8ebf2b" dependencies = [ "bitflags", ] @@ -3757,6 +3783,7 @@ dependencies = [ "quick-xml", "rmp-serde", "serde", + "serde_json", "sqlx", "struct-patch", "thiserror 2.0.18", @@ -4268,12 +4295,12 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.24.0" +version = "3.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c" +checksum = "0136791f7c95b1f6dd99f9cc786b91bb81c3800b639b3478e561ddb7be95e5f1" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.1", "once_cell", "rustix", "windows-sys 0.61.2", @@ -4470,9 +4497,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.9.11+spec-1.1.0" +version = "0.9.12+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3afc9a848309fe1aaffaed6e1546a7a14de1f935dc9d89d32afd9a44bab7c46" +checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863" dependencies = [ "serde_core", "serde_spanned", @@ -4492,9 +4519,9 @@ dependencies = [ [[package]] name = "toml_parser" -version = "1.0.6+spec-1.1.0" +version = "1.0.7+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3198b4b0a8e11f09dd03e133c0280504d0801269e9afa46362ffde1cbeebf44" +checksum = "247eaa3197818b831697600aadf81514e577e0cba5eab10f7e064e78ae154df1" dependencies = [ "winnow", ] @@ -4966,6 +4993,15 @@ dependencies = [ "wit-bindgen", ] +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + [[package]] name = "wasite" version = "0.1.0" @@ -5040,6 +5076,28 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + [[package]] name = "wasm-streams" version = "0.4.2" @@ -5075,6 +5133,18 @@ dependencies = [ "syn 2.0.114", ] +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + [[package]] name = "web-push" version = "0.10.4" @@ -5453,6 +5523,88 @@ name = "wit-bindgen" version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn 2.0.114", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.114", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] [[package]] name = "writeable" diff --git a/backend/Cargo.toml b/backend/Cargo.toml index ad4d9cc..17a8400 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [features] -default = ["swagger"] # push-notifications kaldırıldı +default = ["swagger"] push-notifications = ["web-push", "openssl"] swagger = ["utoipa-swagger-ui"] @@ -28,7 +28,7 @@ clap = { version = "4.4", features = ["derive", "env"] } rust-embed = "8.2" mime_guess = "2.0" shared = { path = "../shared", features = ["ssr"] } -thiserror = "2.0.18" +thiserror = "2.0" dotenvy = "0.15.7" utoipa = { version = "5.4.0", features = ["axum_extras"] } utoipa-swagger-ui = { version = "9.0", features = ["axum"], optional = true } @@ -38,12 +38,13 @@ openssl = { version = "0.10", features = ["vendored"], optional = true } bcrypt = "0.17.0" axum-extra = { version = "0.10", features = ["cookie"] } rand = "0.8" -anyhow = "1.0.101" -time = { version = "0.3.47", features = ["serde", "formatting", "parsing"] } +anyhow = "1.0" +time = { version = "0.3", features = ["serde", "formatting", "parsing"] } tower_governor = "0.8.0" governor = "0.10.4" # Leptos leptos = { version = "0.8.15", features = ["nightly", "msgpack"] } leptos_axum = { version = "0.8.7" } +leptos_router = { version = "0.8.11" } jsonwebtoken = "9" \ No newline at end of file diff --git a/backend/src/main.rs b/backend/src/main.rs index 11995eb..776b5d2 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -26,7 +26,7 @@ use std::time::Duration; use tokio::sync::{broadcast, watch}; use tower::ServiceBuilder; use tower_http::{ - compression::{CompressionLayer, CompressionLevel}, + compression::CompressionLayer, cors::CorsLayer, trace::TraceLayer, }; @@ -407,37 +407,37 @@ async fn main() { } }); +async fn server_fn_handler( + axum::extract::State(state): axum::extract::State, + req: Request, +) -> impl axum::response::IntoResponse { + let scgi_path = state.scgi_socket_path.clone(); + let db = state.db.clone(); + + leptos_axum::handle_server_fns_with_context( + move || { + leptos::context::provide_context(shared::ServerContext { + scgi_socket_path: scgi_path.clone(), + }); + leptos::context::provide_context(shared::DbContext { + db: db.clone(), + }); + }, + req, + ).await +} + let app = Router::new(); #[cfg(feature = "swagger")] let app = app.merge(SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", ApiDoc::openapi())); // Setup & Auth Routes (cookie-based, stay as REST) - // Setup & Auth Routes (cookie-based, stay as REST) - let scgi_path_for_ctx = args.socket.clone(); - let db_for_ctx = db.clone(); let app = app .route("/api/events", get(sse::sse_handler)) - .route("/api/server_fns/{*fn_name}", post({ - let scgi_path = scgi_path_for_ctx.clone(); - let db = db_for_ctx.clone(); - move |req: Request| { - let scgi_path = scgi_path.clone(); - let db = db.clone(); - leptos_axum::handle_server_fns_with_context( - move || { - leptos::context::provide_context(shared::ServerContext { - scgi_socket_path: scgi_path.clone(), - }); - leptos::context::provide_context(shared::DbContext { - db: db.clone(), - }); - }, - req, - ) - } - })) - .fallback(handlers::static_handler); + .route("/api/server_fns/{*fn_name}", post(server_fn_handler)) + .fallback(handlers::static_handler) + .with_state(app_state.clone()); let app = app .layer(middleware::from_fn_with_state(app_state.clone(), auth_middleware)) @@ -445,8 +445,7 @@ async fn main() { .layer( CompressionLayer::new() .br(false) - .gzip(true) - .quality(CompressionLevel::Fastest), + .gzip(true), ) .layer( ServiceBuilder::new() diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 5606b4d..7bcbdc3 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -6,15 +6,16 @@ edition = "2021" [dependencies] serde = { version = "1.0", features = ["derive"] } utoipa = { version = "5.4.0", features = ["axum_extras"] } +serde_json = "1" struct-patch = "0.5" rmp-serde = "1.3" bytes = "1" http = "1" tracing = "0.1" -# Leptos 0.8.7 +# Leptos 0.8 leptos = { version = "0.8.15", features = ["nightly", "msgpack"] } -leptos_router = { version = "0.8.7", features = ["nightly"] } +leptos_router = { version = "0.8.11", features = ["nightly"] } leptos_axum = { version = "0.8.7", optional = true } axum = { version = "0.8", features = ["macros"], optional = true }