from fastapi import APIRouter, Depends
from sse_starlette.sse import EventSourceResponse

from api.dependencies import get_flight_api
from components.flight_api import FlightAPIBase

router = APIRouter()


@router.get("/{flight_id}")
async def stream_events(
    flight_id: str,
    api: FlightAPIBase = Depends(get_flight_api),
) -> EventSourceResponse:
    return EventSourceResponse(api.stream_events(flight_id))

