Implement GET /api/cycle/current endpoint (P1.3)
Add endpoint returning current cycle day, phase, phase configuration, and days until next phase. Uses withAuth middleware for authentication. Response shape: - cycleDay: current day in menstrual cycle (1-31) - phase: current phase (MENSTRUAL, FOLLICULAR, OVULATION, EARLY_LUTEAL, LATE_LUTEAL) - phaseConfig: full configuration including weeklyLimit, trainingType - daysUntilNextPhase: days remaining in current phase - cycleLength: user's configured cycle length Includes 10 tests covering: - Authentication (401 when not authenticated) - Validation (400 when no lastPeriodDate) - All five cycle phases - Cycle rollover handling - Custom cycle lengths 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,7 @@ This file is maintained by Ralph. Run `./ralph-sandbox.sh plan 3` to generate ta
|
||||
| GET /api/user | **COMPLETE** | Returns user profile with `withAuth()` |
|
||||
| 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 | 501 | Returns Not Implemented |
|
||||
| GET /api/cycle/current | **COMPLETE** | Returns cycle day, phase, config, daysUntilNextPhase (10 tests) |
|
||||
| GET /api/today | 501 | Returns Not Implemented |
|
||||
| POST /api/overrides | 501 | Returns Not Implemented |
|
||||
| DELETE /api/overrides | 501 | Returns Not Implemented |
|
||||
@@ -72,6 +72,7 @@ This file is maintained by Ralph. Run `./ralph-sandbox.sh plan 3` to generate ta
|
||||
| `src/middleware.test.ts` | **EXISTS** - 12 tests (page protection, public routes, static assets) |
|
||||
| `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/lib/nutrition.test.ts` | **MISSING** |
|
||||
| `src/lib/email.test.ts` | **MISSING** |
|
||||
| `src/lib/ics.test.ts` | **MISSING** |
|
||||
@@ -164,12 +165,14 @@ Minimum viable product - app can be used for daily decisions.
|
||||
- **Why:** Cycle tracking is the foundation of all recommendations
|
||||
- **Depends On:** P0.1, P0.2
|
||||
|
||||
### P1.3: GET /api/cycle/current Implementation
|
||||
- [ ] Return current cycle day, phase, and phase config
|
||||
### P1.3: GET /api/cycle/current Implementation ✅ COMPLETE
|
||||
- [x] Return current cycle day, phase, and phase config
|
||||
- **Files:**
|
||||
- `src/app/api/cycle/current/route.ts` - Implement GET using cycle.ts utilities
|
||||
- `src/app/api/cycle/current/route.ts` - Implemented GET using cycle.ts utilities with `withAuth()` wrapper
|
||||
- **Tests:**
|
||||
- `src/app/api/cycle/current/route.test.ts` - Test phase calculation, config response
|
||||
- `src/app/api/cycle/current/route.test.ts` - 10 tests covering auth, validation, all phases, cycle rollover, custom cycle lengths
|
||||
- **Response Shape:**
|
||||
- `cycleDay`, `phase`, `phaseConfig`, `daysUntilNextPhase`, `cycleLength`
|
||||
- **Why:** Dashboard needs this for display
|
||||
- **Depends On:** P0.1, P0.2, P1.2
|
||||
|
||||
@@ -483,6 +486,7 @@ P2.14 Mini calendar
|
||||
### API Routes
|
||||
- [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)
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user