Fix Invalid Date error in auth middleware
All checks were successful
Deploy / deploy (push) Successful in 2m28s

Add parseDate helper that safely returns null for empty/invalid date
strings from PocketBase. This prevents RangeError when pino logger
tries to serialize Invalid Date objects via toISOString().

- Make garminTokenExpiresAt and lastPeriodDate nullable in User type
- Filter garmin-sync cron to skip users without required dates
- Add test assertions for null date handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-12 14:13:02 +00:00
parent 63023550fd
commit 72706bb91b
5 changed files with 60 additions and 9 deletions

View File

@@ -27,7 +27,8 @@ vi.mock("@/lib/pocketbase", () => ({
id: user.id,
email: user.email,
calendarToken: user.calendarToken,
lastPeriodDate: user.lastPeriodDate.toISOString(),
// biome-ignore lint/style/noNonNullAssertion: mock user has valid date
lastPeriodDate: user.lastPeriodDate!.toISOString(),
cycleLength: user.cycleLength,
garminConnected: user.garminConnected,
};