From b126987b63bab0bd9d5f229d43bf9cef83ace77b Mon Sep 17 00:00:00 2001 From: Richie Cahill Date: Mon, 15 Jun 2026 21:08:55 -0400 Subject: [PATCH] added AppConfig and AppEngine --- python/ebook_search/api/dependencies.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 python/ebook_search/api/dependencies.py diff --git a/python/ebook_search/api/dependencies.py b/python/ebook_search/api/dependencies.py new file mode 100644 index 0000000..e5a89fa --- /dev/null +++ b/python/ebook_search/api/dependencies.py @@ -0,0 +1,24 @@ +"""FastAPI dependencies for the EPUB search app.""" + +from __future__ import annotations + +from typing import Annotated + +from fastapi import Depends, Request +from sqlalchemy.engine import Engine + +from python.ebook_search.config import EbookSearchConfig + + +def get_config(request: Request) -> EbookSearchConfig: + """Get the loaded search config from app state.""" + return request.app.state.config + + +def get_engine(request: Request) -> Engine: + """Get the database engine from app state.""" + return request.app.state.engine + + +AppConfig = Annotated[EbookSearchConfig, Depends(get_config)] +AppEngine = Annotated[Engine, Depends(get_engine)]