Silence warnings, run cargo fmt

This commit is contained in:
Evan Carroll 2026-01-18 16:27:31 -06:00
parent fe1c1d3655
commit af1c767f5f
77 changed files with 1904 additions and 903 deletions

View file

@ -4,16 +4,14 @@
//! with the admin interface lazy-loaded to reduce initial WASM bundle size.
use leptos::prelude::*;
use leptos_meta::{provide_meta_context, MetaTags, Stylesheet, Title};
use leptos_meta::{MetaTags, Stylesheet, Title, provide_meta_context};
use leptos_router::{
components::{Route, Router, Routes},
ParamSegment, StaticSegment,
components::{Route, Router, Routes},
};
// Re-export user pages for inline route definitions
use chattyness_user_ui::pages::{
HomePage, LoginPage, PasswordResetPage, RealmPage, SignupPage,
};
use chattyness_user_ui::pages::{HomePage, LoginPage, PasswordResetPage, RealmPage, SignupPage};
// Lazy-load admin pages to split WASM bundle
// Each lazy function includes the admin CSS stylesheet for on-demand loading
@ -34,7 +32,8 @@ fn lazy_login() -> AnyView {
<chattyness_admin_ui::components::LoginLayout>
<chattyness_admin_ui::pages::LoginPage />
</chattyness_admin_ui::components::LoginLayout>
}.into_any()
}
.into_any()
}
#[lazy]

View file

@ -6,7 +6,7 @@
mod app;
pub use app::{combined_shell, CombinedApp};
pub use app::{CombinedApp, combined_shell};
#[cfg(feature = "ssr")]
pub use app::CombinedAppState;

View file

@ -11,7 +11,7 @@ mod server {
use axum::Router;
use clap::Parser;
use leptos::prelude::*;
use leptos_axum::{generate_route_list, LeptosRoutes};
use leptos_axum::{LeptosRoutes, generate_route_list};
use sqlx::postgres::PgPoolOptions;
use std::net::SocketAddr;
use std::path::{Path, PathBuf};
@ -20,7 +20,7 @@ mod server {
use tower_http::services::ServeDir;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use chattyness_app::{combined_shell, CombinedApp, CombinedAppState};
use chattyness_app::{CombinedApp, CombinedAppState, combined_shell};
use chattyness_shared::AppConfig;
use chattyness_user_ui::api::WebSocketState;
@ -57,8 +57,9 @@ mod server {
// Initialize logging
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "chattyness_app=debug,chattyness_user_ui=debug,tower_http=debug".into()),
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
"chattyness_app=debug,chattyness_user_ui=debug,tower_http=debug".into()
}),
)
.with(tracing_subscriber::fmt::layer())
.init();
@ -100,9 +101,8 @@ mod server {
let cleanup_pool = pool.clone();
let cleanup_config = config.cleanup.clone();
tokio::spawn(async move {
let mut interval = tokio::time::interval(Duration::from_secs(
cleanup_config.reap_interval_secs,
));
let mut interval =
tokio::time::interval(Duration::from_secs(cleanup_config.reap_interval_secs));
loop {
interval.tick().await;
let threshold = cleanup_config.stale_threshold_secs as f64;
@ -138,9 +138,11 @@ mod server {
let addr = SocketAddr::new(args.host.parse()?, args.port);
// Create session layer (shared between user and admin interfaces)
let session_layer =
chattyness_user_ui::auth::session::create_session_layer(pool.clone(), args.secure_cookies)
.await;
let session_layer = chattyness_user_ui::auth::session::create_session_layer(
pool.clone(),
args.secure_cookies,
)
.await;
// Create combined app state
let app_state = CombinedAppState {
@ -183,10 +185,9 @@ mod server {
};
// Build nested API routers with their own state
let user_api_router = chattyness_user_ui::api::api_router()
.with_state(user_api_state);
let admin_api_router = chattyness_admin_ui::api::admin_api_router()
.with_state(admin_api_state);
let user_api_router = chattyness_user_ui::api::api_router().with_state(user_api_state);
let admin_api_router =
chattyness_admin_ui::api::admin_api_router().with_state(admin_api_state);
// Create RLS layer for row-level security
let rls_layer = chattyness_user_ui::auth::RlsLayer::new(pool.clone());
@ -216,16 +217,30 @@ mod server {
.with_state(app_state)
// Serve pkg files at /pkg (wasm_split hardcodes /pkg/ imports)
// Fallback to split_pkg_dir for --split mode output
.nest_service("/pkg", ServeDir::new(&pkg_dir).fallback(ServeDir::new(&split_pkg_dir)))
.nest_service(
"/pkg",
ServeDir::new(&pkg_dir).fallback(ServeDir::new(&split_pkg_dir)),
)
// Uploaded assets (realm backgrounds, etc.) - must come before /static
.nest_service("/static/realm", ServeDir::new(assets_dir.join("realm")))
// Server-level assets (avatar props, etc.)
.nest_service("/static/server", ServeDir::new(assets_dir.join("server")))
// Also serve at /static for backwards compatibility
.nest_service("/static", ServeDir::new(&pkg_dir).fallback(ServeDir::new(&split_pkg_dir)))
.nest_service("/favicon.ico", tower_http::services::ServeFile::new(public_dir.join("favicon.ico")))
.nest_service(
"/static",
ServeDir::new(&pkg_dir).fallback(ServeDir::new(&split_pkg_dir)),
)
.nest_service(
"/favicon.ico",
tower_http::services::ServeFile::new(public_dir.join("favicon.ico")),
)
// Serve icons from public/icons
.nest_service("/icons", ServeDir::new(public_dir.join("icons")))
// Serve admin CSS at standardized path (symlinked from owner build)
.nest_service("/static/css/admin.css", tower_http::services::ServeFile::new(public_dir.join("admin.css")))
.nest_service(
"/static/css/admin.css",
tower_http::services::ServeFile::new(public_dir.join("admin.css")),
)
// Apply middleware layers (order: session outer, rls inner)
.layer(rls_layer)
.layer(session_layer);

View file

@ -6,17 +6,17 @@
#[cfg(feature = "ssr")]
mod server {
use axum::{response::Redirect, routing::get, Router};
use axum::{Router, response::Redirect, routing::get};
use clap::Parser;
use leptos::prelude::*;
use leptos_axum::{generate_route_list, LeptosRoutes};
use leptos_axum::{LeptosRoutes, generate_route_list};
use sqlx::postgres::PgPoolOptions;
use std::net::SocketAddr;
use std::path::Path;
use tower_http::services::ServeDir;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use chattyness_admin_ui::{admin_shell, AdminApp, AdminAppState};
use chattyness_admin_ui::{AdminApp, AdminAppState, admin_shell};
/// CLI arguments.
#[derive(Parser)]
@ -77,9 +77,11 @@ mod server {
let addr = SocketAddr::new(args.host.parse()?, args.port);
// Create session layer
let session_layer =
chattyness_admin_ui::auth::create_admin_session_layer(pool.clone(), args.secure_cookies)
.await;
let session_layer = chattyness_admin_ui::auth::create_admin_session_layer(
pool.clone(),
args.secure_cookies,
)
.await;
// Create app state
let app_state = AdminAppState {
@ -111,15 +113,24 @@ mod server {
// Redirect root to admin
.route("/", get(|| async { Redirect::permanent("/admin") }))
// Nest API routes under /api/admin (matches frontend expectations when UI is at /admin)
.nest("/api/admin", chattyness_admin_ui::api::admin_api_router().with_state(app_state.clone()))
.nest(
"/api/admin",
chattyness_admin_ui::api::admin_api_router().with_state(app_state.clone()),
)
// Uploaded assets (realm backgrounds, props, etc.) - must come before /static
.nest_service("/assets/server", ServeDir::new(assets_dir.join("server")))
.nest_service("/static/realm", ServeDir::new(assets_dir.join("realm")))
// Static files (build output: JS, CSS, WASM)
.nest_service("/static", ServeDir::new(&static_dir))
.nest_service("/favicon.ico", tower_http::services::ServeFile::new(&favicon_path))
.nest_service(
"/favicon.ico",
tower_http::services::ServeFile::new(&favicon_path),
)
// Serve admin CSS at standardized path
.nest_service("/static/css/admin.css", tower_http::services::ServeFile::new(&admin_css_path))
.nest_service(
"/static/css/admin.css",
tower_http::services::ServeFile::new(&admin_css_path),
)
// Leptos routes
.leptos_routes(&app_state, routes, {
let leptos_options = leptos_options.clone();