Merge branch '40-reduce-dependencies-and-their-features' into 'main'

Reduce dependencies and their features

Closes #40

See merge request libretunes/libretunes!27
This commit is contained in:
Ethan Girouard 2024-05-18 20:29:27 -04:00
commit 7bcb5f8c04
5 changed files with 28 additions and 62 deletions

29
Cargo.lock generated
View File

@ -159,15 +159,11 @@ dependencies = [
"pin-project-lite",
"rustversion",
"serde",
"serde_json",
"serde_path_to_error",
"serde_urlencoded",
"sync_wrapper 1.0.0",
"tokio",
"tower",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
@ -188,7 +184,6 @@ dependencies = [
"sync_wrapper 0.1.2",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
@ -1588,7 +1583,6 @@ dependencies = [
"diesel_migrations",
"dotenv",
"flexi_logger",
"futures",
"http",
"icondata",
"lazy_static",
@ -1609,7 +1603,6 @@ dependencies = [
"tokio",
"tower",
"tower-http",
"tower-sessions",
"tower-sessions-redis-store",
"wasm-bindgen",
"web-sys",
@ -2337,16 +2330,6 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_path_to_error"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6"
dependencies = [
"itoa",
"serde",
]
[[package]]
name = "serde_qs"
version = "0.12.0"
@ -2376,18 +2359,6 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
dependencies = [
"form_urlencoded",
"itoa",
"ryu",
"serde",
]
[[package]]
name = "server_fn"
version = "0.6.11"

View File

@ -8,33 +8,31 @@ build = "src/build.rs"
crate-type = ["cdylib", "rlib"]
[dependencies]
console_error_panic_hook = "0.1"
console_error_panic_hook = { version = "0.1", optional = true }
cfg-if = "1"
http = "1.0"
leptos = { version = "0.6", features = ["nightly"] }
http = { version = "1.0", default-features = false }
leptos = { version = "0.6", default-features = false, features = ["nightly"] }
leptos_meta = { version = "0.6", features = ["nightly"] }
leptos_axum = { version = "0.6", optional = true }
leptos_router = { version = "0.6", features = ["nightly"] }
wasm-bindgen = "=0.2.92"
wasm-bindgen = { version = "=0.2.92", default-features = false, optional = true }
leptos_icons = { version = "0.3.0" }
icondata = { version = "0.3.0" }
dotenv = { version = "0.15.0", optional = true }
diesel = { version = "2.1.4", features = ["postgres", "r2d2", "time"], optional = true }
diesel = { version = "2.1.4", features = ["postgres", "r2d2", "time"], default-features = false, optional = true }
lazy_static = { version = "1.4.0", optional = true }
serde = { version = "1.0.195", features = ["derive"] }
serde = { version = "1.0.195", features = ["derive"], default-features = false }
openssl = { version = "0.10.63", optional = true }
time = { version = "0.3.34", features = ["serde"] }
time = { version = "0.3.34", features = ["serde"], default-features = false }
diesel_migrations = { version = "2.1.0", optional = true }
pbkdf2 = { version = "0.12.2", features = ["simple"], optional = true }
futures = { version = "0.3.30", default-features = false, optional = true }
tokio = { version = "1", optional = true, features = ["rt-multi-thread"] }
axum = { version = "0.7.5", optional = true }
axum = { version = "0.7.5", features = ["tokio", "http1"], default-features = false, optional = true }
tower = { version = "0.4.13", optional = true }
tower-http = { version = "0.5", optional = true, features = ["fs"] }
thiserror = "1.0.57"
tower-sessions = { version = "0.11", default-features = false }
tower-sessions-redis-store = { version = "0.11", optional = true }
async-trait = "0.1.79"
async-trait = { version = "0.1.79", optional = true }
axum-login = { version = "0.14.0", optional = true }
server_fn = { version = "0.6.11", features = ["multipart"] }
symphonia = { version = "0.5.4", default-features = false, features = ["mp3"], optional = true }
@ -47,8 +45,13 @@ web-sys = "0.3.69"
gloo-net = { git = "https://github.com/rustwasm/gloo.git", rev = "a823fab7ecc4068e9a28bd669da5eaf3f0a56380" }
[features]
csr = ["leptos/csr", "leptos_meta/csr", "leptos_router/csr"]
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate"]
hydrate = [
"leptos/hydrate",
"leptos_meta/hydrate",
"leptos_router/hydrate",
"console_error_panic_hook",
"wasm-bindgen",
]
ssr = [
"dep:leptos_axum",
"leptos/ssr",
@ -60,12 +63,12 @@ ssr = [
"openssl",
"diesel_migrations",
"pbkdf2",
"futures",
"tokio",
"axum",
"tower",
"tower-http",
"tower-sessions-redis-store",
"async-trait",
"axum-login",
"symphonia",
"multer",

View File

@ -1,10 +1,17 @@
use async_trait::async_trait;
use axum_login::{AuthnBackend, AuthUser, UserId};
use crate::users::UserCredentials;
use leptos::server_fn::error::ServerFnErrorErr;
use crate::models::User;
use cfg_if::cfg_if;
cfg_if! {
if #[cfg(feature = "ssr")] {
use async_trait::async_trait;
}
}
impl AuthUser for User {
type Id = i32;

View File

@ -19,7 +19,7 @@ async fn main() {
use leptos_axum::{generate_route_list, LeptosRoutes};
use libretunes::app::*;
use libretunes::fileserv::{file_and_error_handler, get_static_file};
use tower_sessions::SessionManagerLayer;
use axum_login::tower_sessions::SessionManagerLayer;
use tower_sessions_redis_store::{fred::prelude::*, RedisStore};
use axum_login::AuthManagerLayerBuilder;
use libretunes::auth_backend::AuthBackend;
@ -72,24 +72,9 @@ async fn main() {
axum::serve(listener, app.into_make_service()).await.expect("Server failed");
}
#[cfg(not(any(feature = "ssr", feature = "csr")))]
#[cfg(not(feature = "ssr"))]
pub fn main() {
// no client-side main function
// unless we want this to work with e.g., Trunk for pure client-side testing
// see lib.rs for hydration function instead
// see optional feature `csr` instead
}
#[cfg(all(not(feature = "ssr"), feature = "csr"))]
pub fn main() {
// a client-side main function is required for using `trunk serve`
// prefer using `cargo leptos serve` instead
// to run: `trunk serve --open --features csr`
use leptos::*;
use libretunes::app::*;
use wasm_bindgen::prelude::wasm_bindgen;
console_error_panic_hook::set_once();
leptos::mount_to_body(App);
}

View File

@ -102,7 +102,7 @@ pub async fn search(query: String, limit: i64) -> Result<(Vec<Album>, Vec<Artist
let artists = search_artists(query.clone(), limit);
let songs = search_songs(query.clone(), limit);
use futures::join;
use tokio::join;
let (albums, artists, songs) = join!(albums, artists, songs);
Ok((albums?, artists?, songs?))