Files
calorie_tracker_2/dist/goals/goals.controller.js
Jp f521970a65 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
2026-01-31 09:00:26 +08:00

80 lines
3.2 KiB
JavaScript

"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.GoalsController = void 0;
const common_1 = require("@nestjs/common");
const authenticated_guard_1 = require("../auth/guards/authenticated.guard");
const goals_service_1 = require("./goals.service");
let GoalsController = class GoalsController {
constructor(goalsService) {
this.goalsService = goalsService;
}
async getGoals(req) {
try {
const data = await this.goalsService.getGoals(req.user.id);
return {
user: req.user,
goals: data.goals,
bmr: data.bmr,
tdee: data.tdee,
};
}
catch (err) {
console.error(err);
req.flash('error_msg', 'Error loading goals');
return {
user: req.user,
goals: null,
bmr: null,
tdee: null,
};
}
}
async updateGoals(req, body, res) {
try {
await this.goalsService.updateGoals(req.user.id, body);
req.flash('success_msg', 'Goals updated successfully!');
res.redirect('/goals');
}
catch (err) {
console.error(err);
req.flash('error_msg', 'Error updating goals');
res.redirect('/goals');
}
}
};
exports.GoalsController = GoalsController;
__decorate([
(0, common_1.Get)(),
(0, common_1.Render)('goals'),
__param(0, (0, common_1.Req)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], GoalsController.prototype, "getGoals", null);
__decorate([
(0, common_1.Post)(),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Body)()),
__param(2, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Object]),
__metadata("design:returntype", Promise)
], GoalsController.prototype, "updateGoals", null);
exports.GoalsController = GoalsController = __decorate([
(0, common_1.Controller)('goals'),
(0, common_1.UseGuards)(authenticated_guard_1.AuthenticatedGuard),
__metadata("design:paramtypes", [goals_service_1.GoalsService])
], GoalsController);
//# sourceMappingURL=goals.controller.js.map