diff --git a/src/application/dto/player_dto.py b/src/application/dto/player_dto.py index 62e4ae4..b9e342f 100644 --- a/src/application/dto/player_dto.py +++ b/src/application/dto/player_dto.py @@ -1,5 +1,5 @@ """Player Data Transfer Objects.""" -from typing import Optional +from typing import Optional, Union from pydantic import BaseModel @@ -59,5 +59,5 @@ class PlayerWithStatsDTO(BaseModel): """Combined player information and statistics.""" player: PlayerDTO - stats: Optional[SkaterStatsDTO | GoalieStatsDTO] + stats: Optional[Union[SkaterStatsDTO, GoalieStatsDTO]] stats_type: str # "skater", "goalie", or "none" diff --git a/src/presentation/api/dependencies.py b/src/presentation/api/dependencies.py index d30fb2d..97f3744 100644 --- a/src/presentation/api/dependencies.py +++ b/src/presentation/api/dependencies.py @@ -3,7 +3,6 @@ from functools import lru_cache from src.domain.repositories import PlayerRepository, TeamRepository, FantasyRepository from src.infrastructure.adapters.nhl import NHLPlayerAdapter, NHLTeamAdapter -from src.infrastructure.adapters.yahoo_fantasy import YahooFantasyAdapter from src.infrastructure.config import Settings, get_settings @@ -40,6 +39,9 @@ def get_fantasy_repository() -> FantasyRepository: This function can be modified to return different implementations without changing any business logic or API code. """ + # Lazy import to avoid requiring yfpy until actually needed + from src.infrastructure.adapters.yahoo_fantasy import YahooFantasyAdapter + settings = get_cached_settings() return YahooFantasyAdapter( consumer_key=settings.yahoo_consumer_key, diff --git a/start_server.sh b/start_server.sh new file mode 100755 index 0000000..71dc4ac --- /dev/null +++ b/start_server.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Startup script for Project Kempe Fantasy Hockey Backend + +cd "$(dirname "$0")" + +echo "==========================================" +echo "Project Kempe - Fantasy Hockey Backend" +echo "==========================================" +echo "" +echo "Starting FastAPI server..." +echo "Server will be available at: http://localhost:8000" +echo "API Documentation: http://localhost:8000/docs" +echo "" +echo "Press Ctrl+C to stop the server" +echo "" + +# Start the server using python module +python3 -m uvicorn src.presentation.api.main:app --reload --host 0.0.0.0 --port 8000