Implement GET /api/today endpoint (P1.4)
Add the core daily snapshot API that powers the dashboard. Returns: - Training decision (status, reason, icon) using decision engine - Cycle data (cycleDay, phase, phaseConfig, daysUntilNextPhase) - Biometrics (hrvStatus, bodyBattery, weekIntensity, phaseLimit) - Nutrition guidance (seeds, carbRange, ketoGuidance) When no DailyLog exists (Garmin not synced), returns sensible defaults: hrvStatus="Unknown", bodyBattery=100, weekIntensity=0. This allows the app to function without Garmin integration. 22 tests covering auth, validation, all decision paths, override handling, phase-specific logic, and nutrition guidance. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,7 @@ This file is maintained by Ralph. Run `./ralph-sandbox.sh plan 3` to generate ta
|
||||
| PATCH /api/user | 501 | Returns Not Implemented |
|
||||
| POST /api/cycle/period | **COMPLETE** | Logs period start, updates user, creates PeriodLog (8 tests) |
|
||||
| GET /api/cycle/current | **COMPLETE** | Returns cycle day, phase, config, daysUntilNextPhase (10 tests) |
|
||||
| GET /api/today | 501 | Returns Not Implemented |
|
||||
| GET /api/today | **COMPLETE** | Returns decision, cycle, biometrics, nutrition (22 tests) |
|
||||
| POST /api/overrides | 501 | Returns Not Implemented |
|
||||
| DELETE /api/overrides | 501 | Returns Not Implemented |
|
||||
| POST /api/garmin/tokens | 501 | Returns Not Implemented |
|
||||
@@ -73,6 +73,7 @@ This file is maintained by Ralph. Run `./ralph-sandbox.sh plan 3` to generate ta
|
||||
| `src/app/api/user/route.test.ts` | **EXISTS** - 4 tests (GET profile, auth, sensitive field exclusion) |
|
||||
| `src/app/api/cycle/period/route.test.ts` | **EXISTS** - 8 tests (POST period, auth, validation, date checks) |
|
||||
| `src/app/api/cycle/current/route.test.ts` | **EXISTS** - 10 tests (GET current cycle, auth, all phases, rollover, custom lengths) |
|
||||
| `src/app/api/today/route.test.ts` | **EXISTS** - 22 tests (daily snapshot, auth, decision, overrides, phases, nutrition, biometrics) |
|
||||
| `src/lib/nutrition.test.ts` | **MISSING** |
|
||||
| `src/lib/email.test.ts` | **MISSING** |
|
||||
| `src/lib/ics.test.ts` | **MISSING** |
|
||||
@@ -176,12 +177,17 @@ Minimum viable product - app can be used for daily decisions.
|
||||
- **Why:** Dashboard needs this for display
|
||||
- **Depends On:** P0.1, P0.2, P1.2
|
||||
|
||||
### P1.4: GET /api/today Implementation
|
||||
- [ ] Return complete daily snapshot with decision, biometrics, nutrition
|
||||
### P1.4: GET /api/today Implementation ✅ COMPLETE
|
||||
- [x] Return complete daily snapshot with decision, biometrics, nutrition
|
||||
- **Files:**
|
||||
- `src/app/api/today/route.ts` - Implement GET aggregating all data sources
|
||||
- `src/app/api/today/route.ts` - Implemented GET with `withAuth()` wrapper, aggregates cycle, biometrics, and nutrition
|
||||
- **Tests:**
|
||||
- `src/app/api/today/route.test.ts` - Test decision computation, data assembly
|
||||
- `src/app/api/today/route.test.ts` - 22 tests covering auth, validation, decision calculation, overrides, phases, nutrition
|
||||
- **Response Shape:**
|
||||
- `decision` (status, reason, icon), `cycleDay`, `phase`, `phaseConfig`, `daysUntilNextPhase`, `cycleLength`
|
||||
- `biometrics` (hrvStatus, bodyBatteryCurrent, bodyBatteryYesterdayLow, weekIntensityMinutes, phaseLimit)
|
||||
- `nutrition` (seeds, carbRange, ketoGuidance)
|
||||
- **Fallback Behavior:** When no DailyLog exists (Garmin not synced), returns defaults: hrvStatus="Unknown", BB=100, weekIntensity=0
|
||||
- **Why:** This is THE core API for the dashboard
|
||||
- **Depends On:** P0.1, P0.2, P0.3, P1.3
|
||||
|
||||
@@ -487,6 +493,7 @@ P2.14 Mini calendar
|
||||
- [x] **GET /api/user** - Returns authenticated user profile, 4 tests (P0.4)
|
||||
- [x] **POST /api/cycle/period** - Logs period start date, updates user, creates PeriodLog, 8 tests (P1.2)
|
||||
- [x] **GET /api/cycle/current** - Returns cycle day, phase, phaseConfig, daysUntilNextPhase, cycleLength, 10 tests (P1.3)
|
||||
- [x] **GET /api/today** - Returns complete daily snapshot with decision, biometrics, nutrition, 22 tests (P1.4)
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user