refactor: consolidate types, remove dead code, and fix minor bugs

Replace DayOfWeek with chrono::Weekday via extension traits, unify
RateLimitConfig into the config module, and remove the unused time
command, BannerState, and ClassDetails stub. Fix open_only query
parameter to respect false values and correct 12-hour time display.
This commit is contained in:
2026-01-28 16:31:11 -06:00
parent 37942378ae
commit 992263205c
27 changed files with 236 additions and 378 deletions
+1 -2
View File
@@ -58,8 +58,7 @@ impl AssetMetadata {
// ETags generated from u64 hex should be 16 characters
etag.len() == 16
// Parse the hexadecimal, compare if it matches
&& etag.parse::<u64>()
&& u64::from_str_radix(etag, 16)
.map(|parsed| parsed == self.hash.0)
.unwrap_or(false)
}
+7 -12
View File
@@ -3,7 +3,7 @@
use axum::{
Router,
body::Body,
extract::{Request, State},
extract::Request,
response::{Json, Response},
routing::get,
};
@@ -20,7 +20,7 @@ use std::{collections::BTreeMap, time::Duration};
#[cfg(not(feature = "embed-assets"))]
use tower_http::cors::{Any, CorsLayer};
use tower_http::{classify::ServerErrorsFailureClass, timeout::TimeoutLayer, trace::TraceLayer};
use tracing::{Span, debug, info, warn};
use tracing::{Span, debug, trace, warn};
#[cfg(feature = "embed-assets")]
use crate::web::assets::{WebAssets, get_asset_metadata_cached};
@@ -62,17 +62,12 @@ fn set_caching_headers(response: &mut Response, path: &str, etag: &str) {
}
}
/// Shared application state for web server
#[derive(Clone)]
pub struct BannerState {}
/// Creates the web server router
pub fn create_router(state: BannerState) -> Router {
pub fn create_router() -> Router {
let api_router = Router::new()
.route("/health", get(health))
.route("/status", get(status))
.route("/metrics", get(metrics))
.with_state(state);
.route("/metrics", get(metrics));
let mut router = Router::new().nest("/api", api_router);
@@ -215,7 +210,7 @@ async fn handle_spa_fallback_with_headers(uri: Uri, request_headers: HeaderMap)
/// Health check endpoint
async fn health() -> Json<Value> {
info!("health check requested");
trace!("health check requested");
Json(json!({
"status": "healthy",
"timestamp": chrono::Utc::now().to_rfc3339()
@@ -246,7 +241,7 @@ struct StatusResponse {
}
/// Status endpoint showing bot and system status
async fn status(State(_state): State<BannerState>) -> Json<StatusResponse> {
async fn status() -> Json<StatusResponse> {
let mut services = BTreeMap::new();
// Bot service status - hardcoded as disabled for now
@@ -297,7 +292,7 @@ async fn status(State(_state): State<BannerState>) -> Json<StatusResponse> {
}
/// Metrics endpoint for monitoring
async fn metrics(State(_state): State<BannerState>) -> Json<Value> {
async fn metrics() -> Json<Value> {
// For now, return basic metrics structure
Json(json!({
"banner_api": {