feat(slice-1): FastAPI factory + /healthz; self-migrate at startup (INV-1/§6.4)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-10 08:38:42 -07:00
parent 9462423642
commit ef385340e8
3 changed files with 90 additions and 2 deletions
+18
View File
@@ -0,0 +1,18 @@
"""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