Initial project scaffold: FastAPI backend + Svelte 5 frontend
Backend (uv): FastAPI app with routers (foods, log, targets, OFF proxy), SQLAlchemy models, Pydantic schemas, migration runner + 0001 initial schema, example pytest suite (7 tests). Frontend (npm): Vite 7 + Svelte 5 runes, lib/ (api, stores, scanner, format) per spec §7, placeholder components, example vitest suite (4 tests). SPEC.md §1: registered uvicorn and Vitest (rule §8.3.3).
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
"""Daily log router (spec §3.3)."""
|
||||
|
||||
from datetime import date
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from database import get_db
|
||||
from models import DailyLogEntry
|
||||
from schemas import LogEntryRead
|
||||
|
||||
router = APIRouter(prefix="/api/log", tags=["log"])
|
||||
|
||||
|
||||
@router.get("", response_model=list[LogEntryRead])
|
||||
def get_log(date: date, db: Session = Depends(get_db)):
|
||||
"""All entries for a client-supplied date (spec §8.1 rule 8)."""
|
||||
stmt = (
|
||||
select(DailyLogEntry)
|
||||
.where(DailyLogEntry.date == date)
|
||||
.order_by(DailyLogEntry.sort_order, DailyLogEntry.id)
|
||||
)
|
||||
return db.scalars(stmt).all()
|
||||
Reference in New Issue
Block a user