The boilerplate's rule: the deploy kit's Dockerfile, the APP_CONFIG, APP_PASSWORD and APP_DATA variables and its commands all assume a package called app, so a project renames its display title and nothing else. The console script is `app`, and the launch entry runs `uv run app serve --port 8790`. The domain noun stays `role`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
812 B
Python
28 lines
812 B
Python
"""How a route reaches the store.
|
|
|
|
Built once by the app's factory and parked on `app.state`; a route asks for
|
|
it as a dependency rather than closing over it, the same split newsdesk's
|
|
`web/deps.py` makes and for the same reason — a router module stays
|
|
importable, and testable, on its own.
|
|
|
|
Not a `yield` dependency: `Store` holds no connection between calls (see
|
|
`app/storage/store.py`), so there is nothing to close, and building one
|
|
per request would take SQLite's write lock for a plain read.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Annotated
|
|
|
|
from fastapi import Depends
|
|
from starlette.requests import HTTPConnection
|
|
|
|
from app.storage import Store
|
|
|
|
|
|
def get_store(request: HTTPConnection) -> Store:
|
|
return request.app.state.store
|
|
|
|
|
|
StoreDep = Annotated[Store, Depends(get_store)]
|