added AppConfig and AppEngine
This commit is contained in:
@@ -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)]
|
||||||
Reference in New Issue
Block a user