add market and odds endpoints

This commit is contained in:
2026-04-09 15:09:43 +02:00
parent 4cc22447c7
commit d45202770e
6 changed files with 244 additions and 0 deletions
+13
View File
@@ -5,12 +5,15 @@ use sqlx::PgPool;
use uuid::Uuid;
pub use crate::events::{EventManifestSnapshot, EventSnapshot};
pub use crate::events::{MarketSnapshot, OutcomeSnapshot};
pub use crate::markets::{OddsVersionSnapshot, OutcomeOddsSnapshot};
pub use crate::sessions::{SessionSnapshot, SessionStartRequest};
use crate::{
config::AppConfig,
error::AppError,
events::{EventsStore},
markets::MarketsStore,
sessions::{SessionDefaults, SessionsStore},
users::{UserCreateRequest, UsersStore},
};
@@ -22,6 +25,7 @@ pub struct AppState {
pub database_pool: Option<PgPool>,
pub redis_client: Option<RedisClient>,
events: EventsStore,
markets: MarketsStore,
users: UsersStore,
sessions: SessionsStore,
}
@@ -38,6 +42,7 @@ impl AppState {
database_pool,
redis_client,
events: EventsStore::new(),
markets: MarketsStore::new(),
users: UsersStore::new(),
sessions: SessionsStore::new(),
}
@@ -96,6 +101,14 @@ impl AppState {
self.events.get_manifest(event_id).await
}
pub async fn markets_for_event(&self, event_id: Uuid) -> Option<Vec<MarketSnapshot>> {
self.markets.markets_for_event(event_id).await
}
pub async fn current_odds(&self, market_id: Uuid) -> Option<OddsVersionSnapshot> {
self.markets.current_odds(market_id).await
}
pub fn database_ready(&self) -> bool {
self.database_pool.is_some()
}