from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles

from gallery.sketch.bundle import ApiBundle
from gallery.util import root_path

from .route import api, doc, view


def build_app(api_bundle: ApiBundle) -> FastAPI:
    app = FastAPI(
        title="Gallery",
        docs_url=None,
        redoc_url=None,
    )
    app.state.api = api_bundle
    app.mount("/static", StaticFiles(directory=root_path / "static/dist"))
    doc.mount(app)
    app.include_router(api.router)
    app.include_router(view.router)
    return app
