from fastapi import FastAPI
from starlette.staticfiles import StaticFiles

from zangramru import ROOT
from zangramru.web.api.router import api_router
from zangramru.web.lifespan import lifespan_setup


def get_app() -> FastAPI:
    """
    Get FastAPI application.

    This is the main constructor of an application.

    :return: application.
    """
    app = FastAPI(
        title="zangramru",
        lifespan=lifespan_setup,
        docs_url="/api/docs",
        redoc_url="/api/redoc",
        openapi_url="/api/openapi.json",
    )

    # Main router for the API.
    app.include_router(router=api_router, prefix="/api")

    app.mount("/", StaticFiles(directory=ROOT / "static", html=True))

    return app
