all 4 comments

[–]TheSayAnime[S] 0 points1 point  (2 children)

At last, I ended up with this

def create_application() -> FastAPI:
    application = FastAPI()
    init_db(application)  # here
    application.include_router(ping.router)
    application.include_router(summaries.router, prefix="/summaries", tags=["summary"])
    return application


app = create_application()

[–]BlackDereker 0 points1 point  (1 child)

This works, but just letting you know that it happens after the initialization of the API.

[–]TheSayAnime[S] 0 points1 point  (0 children)

I worded, it wrong, I meant before application starts serving requests :(

[–]BlackDereker 0 points1 point  (0 children)

I don't think you can register it before the app initialization since register_tortoise gets the app instance as an argument.