From 27b0cb877eaf23800757ef49502f30e1f75025f7 Mon Sep 17 00:00:00 2001 From: Xevion Date: Sat, 13 Sep 2025 18:58:30 -0500 Subject: [PATCH] feat: display project version on frontend --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/web/routes.rs | 18 +++--------- web/src/lib/api.ts | 1 + web/src/routes/index.tsx | 61 +++++++++++++++++++++++++++++----------- 5 files changed, 51 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c12c40..04b3ddc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "banner" -version = "0.3.2" +version = "0.3.3" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index b664f9d..4cb19fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "banner" -version = "0.3.2" +version = "0.3.3" edition = "2024" default-run = "banner" diff --git a/src/web/routes.rs b/src/web/routes.rs index c5b01ef..df0a405 100644 --- a/src/web/routes.rs +++ b/src/web/routes.rs @@ -102,9 +102,8 @@ pub fn create_router(state: BannerState) -> Router { }; // Format latency, status, and code - let (latency_str, status, code) = ( + let (latency_str, status) = ( format!("{latency:.2?}"), - response.status().as_u16(), format!( "{} {}", response.status().as_u16(), @@ -114,19 +113,9 @@ pub fn create_router(state: BannerState) -> Router { // Log in warn if latency is above threshold, otherwise debug if latency > latency_threshold { - warn!( - latency = latency_str, - status = status, - code = code, - "Response" - ); + warn!(latency = latency_str, status = status, "Response"); } else { - debug!( - latency = latency_str, - status = status, - code = code, - "Response" - ); + debug!(latency = latency_str, status = status, "Response"); } }, ) @@ -227,6 +216,7 @@ async fn status(State(_state): State) -> Json { // For now, return basic status without accessing private fields Json(json!({ "status": "operational", + "version": env!("CARGO_PKG_VERSION"), "bot": { "status": "running", "uptime": "TODO: implement uptime tracking" diff --git a/web/src/lib/api.ts b/web/src/lib/api.ts index 4e66039..e1aca20 100644 --- a/web/src/lib/api.ts +++ b/web/src/lib/api.ts @@ -8,6 +8,7 @@ export interface HealthResponse { export interface StatusResponse { status: string; + version: string; bot: { status: string; uptime: string; diff --git a/web/src/routes/index.tsx b/web/src/routes/index.tsx index 96f3f3f..3e12528 100644 --- a/web/src/routes/index.tsx +++ b/web/src/routes/index.tsx @@ -234,27 +234,54 @@ function App() { )} - {status?.git?.commit && ( - - - + {status?.version && ( + + v{status.version} + + )} + {status?.version && status?.git?.commit && ( +