build: add TypeScript configuration and generate declaration files

- Add tsconfig.json for TypeScript compilation with declaration and source map generation
- Generate .d.ts declaration files for all modules, services, controllers, and models
- Update package.json with NestJS dependencies and TypeScript development tools
- Include database files in the distribution output for persistence
This commit is contained in:
Jp
2026-01-31 09:00:26 +08:00
parent 0fa0343798
commit f521970a65
174 changed files with 7205 additions and 1633 deletions

83
dist/dashboard/progress.controller.js vendored Normal file
View File

@@ -0,0 +1,83 @@
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProgressController = void 0;
const common_1 = require("@nestjs/common");
const authenticated_guard_1 = require("../auth/guards/authenticated.guard");
const utils_service_1 = require("../utils/utils.service");
let ProgressController = class ProgressController {
constructor(utilsService) {
this.utilsService = utilsService;
}
async getProgress(req, daysQuery) {
try {
const days = parseInt(daysQuery) || 30;
const weightTrend = await this.utilsService.getWeightTrend(req.user.id, days);
const calorieTrend = await this.utilsService.getCalorieTrend(req.user.id, days);
let avgCalories = 0, avgProtein = 0, avgCarbs = 0, avgFat = 0;
if (calorieTrend.length > 0) {
avgCalories = calorieTrend.reduce((sum, d) => sum + d.calories, 0) / calorieTrend.length;
avgProtein = calorieTrend.reduce((sum, d) => sum + d.protein, 0) / calorieTrend.length;
avgCarbs = calorieTrend.reduce((sum, d) => sum + d.carbs, 0) / calorieTrend.length;
avgFat = calorieTrend.reduce((sum, d) => sum + d.fat, 0) / calorieTrend.length;
}
let weightChange = null;
if (weightTrend.length >= 2) {
weightChange = weightTrend[weightTrend.length - 1].weight_kg - weightTrend[0].weight_kg;
}
return {
user: req.user,
weight_trend: weightTrend,
calorie_trend: calorieTrend,
avg_calories: Math.round(avgCalories),
avg_protein: Math.round(avgProtein),
avg_carbs: Math.round(avgCarbs),
avg_fat: Math.round(avgFat),
weight_change: weightChange,
days,
};
}
catch (err) {
console.error(err);
req.flash('error_msg', 'Error loading progress');
return {
user: req.user,
weight_trend: [],
calorie_trend: [],
avg_calories: 0,
avg_protein: 0,
avg_carbs: 0,
avg_fat: 0,
weight_change: null,
days: 30,
};
}
}
};
exports.ProgressController = ProgressController;
__decorate([
(0, common_1.Get)(),
(0, common_1.Render)('progress'),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Query)('days')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String]),
__metadata("design:returntype", Promise)
], ProgressController.prototype, "getProgress", null);
exports.ProgressController = ProgressController = __decorate([
(0, common_1.Controller)('progress'),
(0, common_1.UseGuards)(authenticated_guard_1.AuthenticatedGuard),
__metadata("design:paramtypes", [utils_service_1.UtilsService])
], ProgressController);
//# sourceMappingURL=progress.controller.js.map