pagepiper/app/deps.py
pyr0ball 4c2370f1de feat(api): add library CRUD endpoints and FastAPI factory
Implements GET/DELETE /api/library, POST /api/library/{id}/reingest,
POST /api/library/scan, and GET /api/library/{id}/status. Adds FastAPI
app factory with lifespan migrations, BM25 singleton wiring, get_db
dependency, ingest task registry with cf-orch/BackgroundTasks fallback,
and placeholder search/chat routers. All 5 new tests pass (14 total).
2026-05-04 17:24:50 -07:00

19 lines
447 B
Python

# app/deps.py
"""FastAPI dependency providers."""
from __future__ import annotations
import sqlite3
from typing import Generator
from app.config import DB_PATH
def get_db() -> Generator[sqlite3.Connection, None, None]:
conn = sqlite3.connect(DB_PATH)
conn.execute("PRAGMA foreign_keys = ON")
conn.execute("PRAGMA journal_mode = WAL")
conn.row_factory = sqlite3.Row
try:
yield conn
finally:
conn.close()