use axum::{Json, extract::State, response::IntoResponse};
use fraiseql_core::db::traits::DatabaseAdapter;
use serde::{Deserialize, Serialize};
use crate::routes::graphql::app_state::AppState;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PresenceRoom {
pub room: String,
pub members: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RealtimeStatsResponse {
pub connections: u32,
pub channels: Vec<String>,
pub presence_rooms: Vec<PresenceRoom>,
pub cdc_lag_ms: Option<u64>,
}
pub async fn stats_handler<A>(State(_state): State<AppState<A>>) -> impl IntoResponse
where
A: DatabaseAdapter + Clone + Send + Sync + 'static,
{
Json(RealtimeStatsResponse {
connections: 0,
channels: vec![],
presence_rooms: vec![],
cdc_lag_ms: None,
})
}
pub async fn broadcast_channels_handler<A>(State(_state): State<AppState<A>>) -> impl IntoResponse
where
A: DatabaseAdapter + Clone + Send + Sync + 'static,
{
Json(serde_json::json!({ "channels": [] }))
}
pub async fn presence_rooms_handler<A>(State(_state): State<AppState<A>>) -> impl IntoResponse
where
A: DatabaseAdapter + Clone + Send + Sync + 'static,
{
Json(serde_json::json!({ "presence_rooms": [] }))
}
pub async fn cdc_lag_handler<A>(State(_state): State<AppState<A>>) -> impl IntoResponse
where
A: DatabaseAdapter + Clone + Send + Sync + 'static,
{
Json(serde_json::json!({ "cdc_lag_ms": null }))
}