Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/garmin-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface CaloriesData {
total: number | null; // Total calories burned (BMR + active)
active: number | null; // Active calories burned
bmr: number | null; // Basal Metabolic Rate calories
consumed: number | null; // Consumed calories (from MyFitnessPal etc.)
}

export interface DailyData {
Expand Down Expand Up @@ -272,10 +273,11 @@ export class GarminClient {
total: result?.totalKilocalories ?? null,
active: result?.activeKilocalories ?? null,
bmr: result?.bmrKilocalories ?? null,
consumed: result?.consumedKilocalories ?? null,
};
} catch (error) {
// Calories data might not be available
return { total: null, active: null, bmr: null };
return { total: null, active: null, bmr: null, consumed: null };
}
}

Expand Down Expand Up @@ -455,7 +457,7 @@ export class GarminClient {
try {
return await this.getDailyCalories(date);
} catch {
return { total: null, active: null, bmr: null };
return { total: null, active: null, bmr: null, consumed: null };
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ app.get('/api/daily', requireGarminClient, async (req: Request, res: Response) =
// Fetch all daily data in parallel
const [steps, calories, heartRate, sleep, weight, hydration] = await Promise.all([
garminClient!.getSteps(date).catch(() => null),
garminClient!.getDailyCalories(date).catch(() => ({ total: null, active: null, bmr: null })),
garminClient!.getDailyCalories(date).catch(() => ({ total: null, active: null, bmr: null, consumed: null })),
garminClient!.getHeartRate(date).catch(() => null),
garminClient!.getSleepData(date).catch(() => null),
garminClient!.getDailyWeightData(date).catch(() => null),
Expand Down