This commit is contained in:
Robin Appelman 2026-03-26 23:44:23 +01:00
commit fb383652c8
22 changed files with 3161 additions and 3071 deletions

1692
api-server/Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,15 +1,16 @@
[package]
name = "ugc-api-server"
version = "0.1.0"
edition = "2021"
edition = "2024"
rust-version = "1.88.0"
[dependencies]
tokio = { version = "1.44.2", features = ["macros", "rt-multi-thread", "rt", "signal"] }
main_error = "0.1.2"
ugc-scraper = { version = "*", path = ".." }
#ugc-scraper = "0.5.0"
#ugc-scraper = "0.6.0"
axum = "0.8.3"
steamid-ng = "1.0.0"
steamid-ng = "3.0.0"
thiserror = "2.0.12"
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }

View file

@ -7,7 +7,7 @@ use std::env::var;
use std::net::Ipv4Addr;
use std::str::FromStr;
use std::sync::Arc;
use steamid_ng::{SteamID, SteamIDError};
use steamid_ng::{SteamID, SteamIDParseError};
use thiserror::Error;
use tokio::net::TcpListener;
use tokio::signal;
@ -24,7 +24,7 @@ struct AppState {
#[derive(Debug, Error)]
enum ApiError {
#[error(transparent)]
SteamId(#[from] SteamIDError),
SteamId(#[from] SteamIDParseError),
#[error(transparent)]
Scrape(#[from] ScrapeError),
#[error("malformed request")]
@ -92,7 +92,7 @@ async fn player(
Path(id): Path<String>,
State(state): State<AppState>,
) -> Result<impl IntoResponse, ApiError> {
let steam_id = SteamID::try_from(id.as_str())?;
let steam_id = SteamID::from_str(id.as_str())?;
debug!(player = steam_id.steam3(), "requesting player");
let response = state.client.player(steam_id).await?;
Ok(Json(response))
@ -103,7 +103,7 @@ async fn player_history(
Path(id): Path<String>,
State(state): State<AppState>,
) -> Result<impl IntoResponse, ApiError> {
let steam_id = SteamID::try_from(id.as_str())?;
let steam_id = SteamID::from_str(id.as_str())?;
debug!(player = steam_id.steam3(), "requesting player history");
let response = state.client.player_team_history(steam_id).await?;
Ok(Json(response))