Implement POST/DELETE /api/overrides endpoints (P1.5)
Add override management API for the training decision system: - POST /api/overrides adds an override (flare, stress, sleep, pms) - DELETE /api/overrides removes an override - Both endpoints use withAuth middleware - Validation for override types, idempotent operations - 14 tests covering auth, validation, and persistence Also fix type error in today/route.ts where DailyLog body battery fields could be null but biometrics object expected numbers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -30,8 +30,8 @@ This file is maintained by Ralph. Run `./ralph-sandbox.sh plan 3` to generate ta
|
||||
| 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 | **COMPLETE** | Returns decision, cycle, biometrics, nutrition (22 tests) |
|
||||
| POST /api/overrides | 501 | Returns Not Implemented |
|
||||
| DELETE /api/overrides | 501 | Returns Not Implemented |
|
||||
| POST /api/overrides | **COMPLETE** | Adds override to user.activeOverrides (14 tests) |
|
||||
| DELETE /api/overrides | **COMPLETE** | Removes override from user.activeOverrides (14 tests) |
|
||||
| POST /api/garmin/tokens | 501 | Returns Not Implemented |
|
||||
| DELETE /api/garmin/tokens | 501 | Returns Not Implemented |
|
||||
| GET /api/garmin/status | 501 | Returns Not Implemented |
|
||||
@@ -74,6 +74,7 @@ This file is maintained by Ralph. Run `./ralph-sandbox.sh plan 3` to generate ta
|
||||
| `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/app/api/overrides/route.test.ts` | **EXISTS** - 14 tests (POST/DELETE overrides, auth, validation, type checks) |
|
||||
| `src/lib/nutrition.test.ts` | **MISSING** |
|
||||
| `src/lib/email.test.ts` | **MISSING** |
|
||||
| `src/lib/ics.test.ts` | **MISSING** |
|
||||
@@ -191,13 +192,16 @@ Minimum viable product - app can be used for daily decisions.
|
||||
- **Why:** This is THE core API for the dashboard
|
||||
- **Depends On:** P0.1, P0.2, P0.3, P1.3
|
||||
|
||||
### P1.5: POST/DELETE /api/overrides Implementation
|
||||
- [ ] Toggle override flags on user record
|
||||
### P1.5: POST/DELETE /api/overrides Implementation ✅ COMPLETE
|
||||
- [x] Toggle override flags on user record
|
||||
- **Files:**
|
||||
- `src/app/api/overrides/route.ts` - Implement POST (add) and DELETE (remove) handlers
|
||||
- `src/app/api/overrides/route.ts` - Implemented POST (add) and DELETE (remove) handlers with validation
|
||||
- **Tests:**
|
||||
- `src/app/api/overrides/route.test.ts` - Test override types, persistence, validation
|
||||
- `src/app/api/overrides/route.test.ts` - 14 tests covering auth, override types, persistence, validation, edge cases
|
||||
- **Override Types:** flare, stress, sleep, pms
|
||||
- **POST Response:** Returns updated user with new override added to activeOverrides array
|
||||
- **DELETE Response:** Returns updated user with override removed from activeOverrides array
|
||||
- **Validation:** Rejects invalid override types, duplicates on POST, missing overrides on DELETE
|
||||
- **Why:** Emergency overrides are critical for flare days
|
||||
- **Depends On:** P0.1, P0.2, P0.3
|
||||
|
||||
@@ -494,6 +498,8 @@ P2.14 Mini calendar
|
||||
- [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)
|
||||
- [x] **POST /api/overrides** - Adds override to user.activeOverrides array, 14 tests (P1.5)
|
||||
- [x] **DELETE /api/overrides** - Removes override from user.activeOverrides array, 14 tests (P1.5)
|
||||
|
||||
---
|
||||
|
||||
@@ -505,6 +511,7 @@ P2.14 Mini calendar
|
||||
- [x] ~~`src/middleware.ts` does not exist~~ - CREATED in P0.2
|
||||
- [ ] `garmin.ts` is only ~30% complete - missing specific biometric fetchers
|
||||
- [x] ~~`pocketbase.ts` missing all auth helper functions~~ - FIXED in P0.1
|
||||
- [x] ~~`src/app/api/today/route.ts` type error with null body battery values~~ - FIXED (added null coalescing)
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user