Files
dotfiles/python/ebook_search/api/dependencies.py
T
2026-06-15 21:08:55 -04:00

25 lines
646 B
Python

"""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)]