def format_sse(event = None, data: str = "") -> str:
    """
    Formats data to the event-stream format.

    https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format
    """
    message = f"data: {data}\n\n"

    # If event is specified, prepend "event: {event}\n"
    if event is not None:
        message = f"event: {event}\n{message}"

    return message