Files
wiggleverse-ecomm/backend/app/platform/deps.py
T
2026-06-10 08:38:42 -07:00

19 lines
582 B
Python

"""FastAPI dependencies — per-request wiring (SD-0001 §6.2 platform/deps).
Yields a pooled connection per request. The pool lives on app.state, built once in
create_app(). Later slices add the current-session and mailer dependencies here.
"""
from __future__ import annotations
from collections.abc import Iterator
import psycopg
from fastapi import Request
def get_conn(request: Request) -> Iterator[psycopg.Connection]:
"""A pooled connection for the duration of one request."""
pool = request.app.state.pool
with pool.connection() as conn:
yield conn