backend/src/api/v1/stats.rs
2025-04-28 23:20:37 +02:00

28 lines
752 B
Rust

use std::time::SystemTime;
use actix_web::{get, web, HttpResponse, Responder};
use serde::Serialize;
use crate::Data;
const VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION");
#[derive(Serialize)]
struct Response {
accounts: usize,
uptime: u64,
version: String,
build_number: String,
}
#[get("/stats")]
pub async fn res(data: web::Data<Data>) -> impl Responder {
let response = Response {
accounts: 0,
uptime: SystemTime::now().duration_since(data.start_time).expect("Seriously why dont you have time??").as_secs(),
version: String::from(VERSION.unwrap_or_else(|| "UNKNOWN")),
build_number: String::from("how do i implement this?"),
};
HttpResponse::Ok().json(response)
}