api: add tooling for keeping a local cache
This commit is contained in:
parent
51349c297b
commit
bc7e74f28d
4 changed files with 22 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ version = "0.1.0"
|
||||||
description = "API for Dooris setup using HomeMatic."
|
description = "API for Dooris setup using HomeMatic."
|
||||||
requires-python = ">=3.13"
|
requires-python = ">=3.13"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"cachetools>=7.1.1",
|
||||||
"fastapi>=0.136.1",
|
"fastapi>=0.136.1",
|
||||||
"simple-openid-connect>=2.4.0",
|
"simple-openid-connect>=2.4.0",
|
||||||
"uvicorn>=0.46.0",
|
"uvicorn>=0.46.0",
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@ async def lifespan(app: FastAPI):
|
||||||
client_id="dooris",
|
client_id="dooris",
|
||||||
client_secret="dp9HhnvUhAtKm3pRnxfGA7q8Nwrd1td8",
|
client_secret="dp9HhnvUhAtKm3pRnxfGA7q8Nwrd1td8",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
app.extra["cache"] = TTLCache(maxsize=64, ttl=30 * 60)
|
||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,3 +69,10 @@ def persist_auth_state(oidc_client: OpenidClient, resp: Response, tokens: TokenS
|
||||||
|
|
||||||
CurrentUser = Annotated[Optional[models.CurrentUser], Depends(get_current_user)]
|
CurrentUser = Annotated[Optional[models.CurrentUser], Depends(get_current_user)]
|
||||||
|
|
||||||
|
|
||||||
|
def get_cache(req: Request) -> Cache:
|
||||||
|
return req.app.extra["cache"]
|
||||||
|
|
||||||
|
|
||||||
|
Cache = Annotated[Cache, Depends(get_cache)]
|
||||||
|
|
||||||
|
|
|
||||||
11
api/uv.lock
generated
11
api/uv.lock
generated
|
|
@ -41,6 +41,15 @@ wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/d2/39/e7eaf1799466a4aef85b6a4fe7bd175ad2b1c6345066aa33f1f58d4b18d0/asttokens-3.0.1-py3-none-any.whl", hash = "sha256:15a3ebc0f43c2d0a50eeafea25e19046c68398e487b9f1f5b517f7c0f40f976a", size = 27047, upload-time = "2025-11-15T16:43:16.109Z" },
|
{ url = "https://files.pythonhosted.org/packages/d2/39/e7eaf1799466a4aef85b6a4fe7bd175ad2b1c6345066aa33f1f58d4b18d0/asttokens-3.0.1-py3-none-any.whl", hash = "sha256:15a3ebc0f43c2d0a50eeafea25e19046c68398e487b9f1f5b517f7c0f40f976a", size = 27047, upload-time = "2025-11-15T16:43:16.109Z" },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cachetools"
|
||||||
|
version = "7.1.1"
|
||||||
|
source = { registry = "https://pypi.org/simple" }
|
||||||
|
sdist = { url = "https://files.pythonhosted.org/packages/ff/e2/85f227594656000ff4d8adadae91a21f536d4a84c6c716a86bd6685874be/cachetools-7.1.1.tar.gz", hash = "sha256:27bdf856d68fd3c71c26c01b5edc312124ed427524d1ddb31aa2b7746fe20d4b", size = 40202, upload-time = "2026-05-03T20:00:29.391Z" }
|
||||||
|
wheels = [
|
||||||
|
{ url = "https://files.pythonhosted.org/packages/bf/0f/f897abe4ea0a8c408ae65c8c83bffab4936ad65d6032d4fb4cd35bbdc3ee/cachetools-7.1.1-py3-none-any.whl", hash = "sha256:0335cd7a0952d2b22327441fb0628139e234c565559eeb91a8a4ac7551c5353d", size = 16775, upload-time = "2026-05-03T20:00:27.857Z" },
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "certifi"
|
name = "certifi"
|
||||||
version = "2026.4.22"
|
version = "2026.4.22"
|
||||||
|
|
@ -253,6 +262,7 @@ name = "dooris-api"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
{ name = "cachetools" },
|
||||||
{ name = "fastapi" },
|
{ name = "fastapi" },
|
||||||
{ name = "simple-openid-connect" },
|
{ name = "simple-openid-connect" },
|
||||||
{ name = "uvicorn" },
|
{ name = "uvicorn" },
|
||||||
|
|
@ -265,6 +275,7 @@ dev = [
|
||||||
|
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
requires-dist = [
|
requires-dist = [
|
||||||
|
{ name = "cachetools", specifier = ">=7.1.1" },
|
||||||
{ name = "fastapi", specifier = ">=0.136.1" },
|
{ name = "fastapi", specifier = ">=0.136.1" },
|
||||||
{ name = "simple-openid-connect", specifier = ">=2.4.0" },
|
{ name = "simple-openid-connect", specifier = ">=2.4.0" },
|
||||||
{ name = "uvicorn", specifier = ">=0.46.0" },
|
{ name = "uvicorn", specifier = ">=0.46.0" },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue