From da3582771ca0ceb242c992cc52a3f5f0ca95c880 Mon Sep 17 00:00:00 2001 From: Eric Lee Date: Wed, 25 Feb 2026 13:40:23 +0900 Subject: [PATCH] add consumed calories (from MyFitnessPal) to calories data --- src/garmin-client.ts | 6 ++++-- src/server.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/garmin-client.ts b/src/garmin-client.ts index ef59c78..aa0baab 100644 --- a/src/garmin-client.ts +++ b/src/garmin-client.ts @@ -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 { @@ -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 }; } } @@ -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 }; } } diff --git a/src/server.ts b/src/server.ts index 5abb611..79ae7d5 100644 --- a/src/server.ts +++ b/src/server.ts @@ -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),