feat(docker): add Docker support and enhance dashboard data

- Add Dockerfile and docker-compose.yml for containerized deployment
- Update server to listen on all network interfaces for Docker compatibility
- Add .dockerignore to exclude unnecessary files from build context
- Enhance dashboard controller with additional user data, trends, and suggestions
- Update package.json scripts for proper Docker build workflow
This commit is contained in:
Jp
2026-02-01 21:26:26 +08:00
parent f521970a65
commit 3dc74b6aa2
12 changed files with 81 additions and 23 deletions

View File

@@ -61,22 +61,42 @@ let DashboardController = class DashboardController {
fat: goals.target_fat_g - nutrition.fat,
water: goals.target_water_ml - water.total_ml,
};
const macroPercentages = this.utilsService.getMacroPercentages(nutrition.protein, nutrition.carbs, nutrition.fat);
const macro_percentages = this.utilsService.getMacroPercentages(nutrition.protein, nutrition.carbs, nutrition.fat);
const suggestions = this.utilsService.suggestFoodsForMacros(remaining.protein, remaining.carbs, remaining.fat);
const calorie_trend = await this.utilsService.getCalorieTrend(req.user.id);
const weight_trend = await this.utilsService.getWeightTrend(req.user.id);
return {
user: req.user,
current_user: req.user,
nutrition,
water,
goals,
weightLogToday,
weightChange,
remaining,
macroPercentages,
macro_percentages,
suggestions,
calorie_trend,
weight_trend,
};
}
catch (err) {
console.error(err);
req.flash('error_msg', 'Error loading dashboard');
return {};
return {
user: req.user,
current_user: req.user,
nutrition: { calories: 0, protein: 0, carbs: 0, fat: 0, meals: [] },
water: { total_ml: 0, logs: [] },
goals: null,
weightLogToday: null,
weightChange: null,
remaining: { calories: 0, protein: 0, carbs: 0, fat: 0, water: 0 },
macro_percentages: { protein: 0, carbs: 0, fat: 0 },
suggestions: [],
calorie_trend: [],
weight_trend: [],
};
}
}
};