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

12
dist/app.controller.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
import { Response } from 'express';
import { UsersService } from './users/users.service';
export declare class AppController {
private usersService;
constructor(usersService: UsersService);
root(req: any, res: Response): void;
login(): {};
loginPost(res: Response): void;
register(): {};
registerPost(body: any, res: Response, req: any): Promise<void>;
logout(req: any, res: Response): void;
}

120
dist/app.controller.js vendored Normal file
View File

@@ -0,0 +1,120 @@
"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.AppController = void 0;
const common_1 = require("@nestjs/common");
const local_auth_guard_1 = require("./auth/guards/local-auth.guard");
const users_service_1 = require("./users/users.service");
let AppController = class AppController {
constructor(usersService) {
this.usersService = usersService;
}
root(req, res) {
if (req.isAuthenticated()) {
return res.redirect('/dashboard');
}
else {
return res.redirect('/login');
}
}
login() {
return {};
}
loginPost(res) {
res.redirect('/dashboard');
}
register() {
return {};
}
async registerPost(body, res, req) {
const { username, password, name } = body;
try {
const existingUser = await this.usersService.findOne(username);
if (existingUser) {
req.flash('error', 'Username already exists');
return res.redirect('/register');
}
await this.usersService.create({ username, password, name });
req.flash('success_msg', 'You are now registered and can log in');
res.redirect('/login');
}
catch (err) {
console.error(err);
req.flash('error', 'Error registering user');
res.redirect('/register');
}
}
logout(req, res) {
req.logout((err) => {
if (err) {
console.error(err);
}
req.flash('success_msg', 'You are logged out');
res.redirect('/login');
});
}
};
exports.AppController = AppController;
__decorate([
(0, common_1.Get)(),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", void 0)
], AppController.prototype, "root", null);
__decorate([
(0, common_1.Get)('login'),
(0, common_1.Render)('login'),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], AppController.prototype, "login", null);
__decorate([
(0, common_1.UseGuards)(local_auth_guard_1.LocalAuthGuard),
(0, common_1.Post)('login'),
__param(0, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], AppController.prototype, "loginPost", null);
__decorate([
(0, common_1.Get)('register'),
(0, common_1.Render)('register'),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], AppController.prototype, "register", null);
__decorate([
(0, common_1.Post)('register'),
__param(0, (0, common_1.Body)()),
__param(1, (0, common_1.Res)()),
__param(2, (0, common_1.Req)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Object]),
__metadata("design:returntype", Promise)
], AppController.prototype, "registerPost", null);
__decorate([
(0, common_1.Get)('logout'),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", void 0)
], AppController.prototype, "logout", null);
exports.AppController = AppController = __decorate([
(0, common_1.Controller)(),
__metadata("design:paramtypes", [users_service_1.UsersService])
], AppController);
//# sourceMappingURL=app.controller.js.map

1
dist/app.controller.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../src/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoG;AAEpG,qEAAgE;AAChE,yDAAqD;AAI9C,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAAoB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAGlD,IAAI,CAAQ,GAAG,EAAS,GAAa;QACnC,IAAI,GAAG,CAAC,eAAe,EAAE,EAAE,CAAC;YAC1B,OAAO,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAID,KAAK;QACH,OAAO,EAAE,CAAC;IACZ,CAAC;IAID,SAAS,CAAQ,GAAa;QAC5B,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC7B,CAAC;IAID,QAAQ;QACN,OAAO,EAAE,CAAC;IACZ,CAAC;IAGK,AAAN,KAAK,CAAC,YAAY,CAAS,IAAI,EAAS,GAAa,EAAS,GAAG;QAC/D,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QAC1C,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC/D,IAAI,YAAY,EAAE,CAAC;gBACjB,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC;gBAC9C,OAAO,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YACnC,CAAC;YACD,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,QAAQ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AA,YAAG,GAAE,CAAA;IAAiB,WAAA,IAAA,YAAG,GAAE,CAAA;;;;iDAgB5D;AAGD;IADC,IAAA,YAAG,EAAC,QAAQ,CAAC;IACN,WAAA,IAAA,YAAG,GAAE,CAAA;IAAO,WAAA,IAAA,YAAG,GAAE,CAAA;;;;2CAQxB;wBA1DU,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAEuB,4BAAY;GADnC,aAAa,CA2DzB"}

4
dist/app.module.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
import { MiddlewareConsumer } from '@nestjs/common';
export declare class AppModule {
configure(consumer: MiddlewareConsumer): void;
}

52
dist/app.module.js vendored Normal file
View File

@@ -0,0 +1,52 @@
"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppModule = void 0;
const common_1 = require("@nestjs/common");
const config_1 = require("@nestjs/config");
const database_module_1 = require("./database/database.module");
const auth_module_1 = require("./auth/auth.module");
const users_module_1 = require("./users/users.module");
const app_controller_1 = require("./app.controller");
const utils_module_1 = require("./utils/utils.module");
const dashboard_module_1 = require("./dashboard/dashboard.module");
const meals_module_1 = require("./meals/meals.module");
const goals_module_1 = require("./goals/goals.module");
const foods_module_1 = require("./foods/foods.module");
const meal_planner_module_1 = require("./meal-planner/meal-planner.module");
const locals_middleware_1 = require("./common/middleware/locals.middleware");
let AppModule = class AppModule {
configure(consumer) {
consumer
.apply(locals_middleware_1.LocalsMiddleware)
.forRoutes({ path: '*', method: common_1.RequestMethod.ALL });
}
};
exports.AppModule = AppModule;
exports.AppModule = AppModule = __decorate([
(0, common_1.Module)({
imports: [
config_1.ConfigModule.forRoot({
isGlobal: true,
envFilePath: '.env',
}),
database_module_1.DatabaseModule,
auth_module_1.AuthModule,
users_module_1.UsersModule,
utils_module_1.UtilsModule,
dashboard_module_1.DashboardModule,
meals_module_1.MealsModule,
goals_module_1.GoalsModule,
foods_module_1.FoodsModule,
meal_planner_module_1.MealPlannerModule,
],
controllers: [app_controller_1.AppController],
providers: [],
})
], AppModule);
//# sourceMappingURL=app.module.js.map

1
dist/app.module.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA2E;AAC3E,2CAA8C;AAC9C,gEAA4D;AAC5D,oDAAgD;AAChD,uDAAmD;AACnD,qDAAiD;AACjD,uDAAmD;AACnD,mEAA+D;AAC/D,uDAAmD;AACnD,uDAAmD;AACnD,uDAAmD;AACnD,4EAAuE;AACvE,6EAAyE;AAqBlE,IAAM,SAAS,GAAf,MAAM,SAAS;IACpB,SAAS,CAAC,QAA4B;QACpC,QAAQ;aACL,KAAK,CAAC,oCAAgB,CAAC;aACvB,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,sBAAa,CAAC,GAAG,EAAE,CAAC,CAAC;IACzD,CAAC;CACF,CAAA;AANY,8BAAS;oBAAT,SAAS;IAnBrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,MAAM;aACpB,CAAC;YACF,gCAAc;YACd,wBAAU;YACV,0BAAW;YACX,0BAAW;YACX,kCAAe;YACf,0BAAW;YACX,0BAAW;YACX,0BAAW;YACX,uCAAiB;SAClB;QACD,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,EAAE;KACd,CAAC;GACW,SAAS,CAMrB"}

2
dist/auth/auth.module.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare class AuthModule {
}

26
dist/auth/auth.module.js vendored Normal file
View File

@@ -0,0 +1,26 @@
"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthModule = void 0;
const common_1 = require("@nestjs/common");
const auth_service_1 = require("./auth.service");
const users_module_1 = require("../users/users.module");
const passport_1 = require("@nestjs/passport");
const local_strategy_1 = require("./local.strategy");
const session_serializer_1 = require("./session.serializer");
let AuthModule = class AuthModule {
};
exports.AuthModule = AuthModule;
exports.AuthModule = AuthModule = __decorate([
(0, common_1.Module)({
imports: [users_module_1.UsersModule, passport_1.PassportModule.register({ session: true })],
providers: [auth_service_1.AuthService, local_strategy_1.LocalStrategy, session_serializer_1.SessionSerializer],
exports: [auth_service_1.AuthService],
})
], AuthModule);
//# sourceMappingURL=auth.module.js.map

1
dist/auth/auth.module.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../src/auth/auth.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iDAA6C;AAC7C,wDAAoD;AACpD,+CAAkD;AAClD,qDAAiD;AACjD,6DAAyD;AAOlD,IAAM,UAAU,GAAhB,MAAM,UAAU;CAAG,CAAA;AAAb,gCAAU;qBAAV,UAAU;IALtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0BAAW,EAAE,yBAAc,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,SAAS,EAAE,CAAC,0BAAW,EAAE,8BAAa,EAAE,sCAAiB,CAAC;QAC1D,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;GACW,UAAU,CAAG"}

6
dist/auth/auth.service.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
import { UsersService } from '../users/users.service';
export declare class AuthService {
private usersService;
constructor(usersService: UsersService);
validateUser(username: string, pass: string): Promise<any>;
}

32
dist/auth/auth.service.js vendored Normal file
View File

@@ -0,0 +1,32 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthService = void 0;
const common_1 = require("@nestjs/common");
const users_service_1 = require("../users/users.service");
let AuthService = class AuthService {
constructor(usersService) {
this.usersService = usersService;
}
async validateUser(username, pass) {
const user = await this.usersService.findOne(username);
if (user && user.validPassword(pass)) {
return user;
}
return null;
}
};
exports.AuthService = AuthService;
exports.AuthService = AuthService = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [users_service_1.UsersService])
], AuthService);
//# sourceMappingURL=auth.service.js.map

1
dist/auth/auth.service.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/auth/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,0DAAsD;AAG/C,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,YAAoB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAElD,KAAK,CAAC,YAAY,CAAC,QAAgB,EAAE,IAAY;QAC/C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvD,IAAI,IAAI,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;YAGrC,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAZY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;qCAEuB,4BAAY;GADnC,WAAW,CAYvB"}

View File

@@ -0,0 +1,4 @@
import { CanActivate, ExecutionContext } from '@nestjs/common';
export declare class AuthenticatedGuard implements CanActivate {
canActivate(context: ExecutionContext): Promise<any>;
}

21
dist/auth/guards/authenticated.guard.js vendored Normal file
View File

@@ -0,0 +1,21 @@
"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthenticatedGuard = void 0;
const common_1 = require("@nestjs/common");
let AuthenticatedGuard = class AuthenticatedGuard {
async canActivate(context) {
const request = context.switchToHttp().getRequest();
return request.isAuthenticated();
}
};
exports.AuthenticatedGuard = AuthenticatedGuard;
exports.AuthenticatedGuard = AuthenticatedGuard = __decorate([
(0, common_1.Injectable)()
], AuthenticatedGuard);
//# sourceMappingURL=authenticated.guard.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"authenticated.guard.js","sourceRoot":"","sources":["../../../src/auth/guards/authenticated.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA2E;AAGpE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,OAAO,OAAO,CAAC,eAAe,EAAE,CAAC;IACnC,CAAC;CACF,CAAA;AALY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAK9B"}

View File

@@ -0,0 +1,6 @@
import { ExecutionContext } from '@nestjs/common';
declare const LocalAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
export declare class LocalAuthGuard extends LocalAuthGuard_base {
canActivate(context: ExecutionContext): Promise<boolean>;
}
export {};

24
dist/auth/guards/local-auth.guard.js vendored Normal file
View File

@@ -0,0 +1,24 @@
"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocalAuthGuard = void 0;
const common_1 = require("@nestjs/common");
const passport_1 = require("@nestjs/passport");
let LocalAuthGuard = class LocalAuthGuard extends (0, passport_1.AuthGuard)('local') {
async canActivate(context) {
const result = (await super.canActivate(context));
const request = context.switchToHttp().getRequest();
await super.logIn(request);
return result;
}
};
exports.LocalAuthGuard = LocalAuthGuard;
exports.LocalAuthGuard = LocalAuthGuard = __decorate([
(0, common_1.Injectable)()
], LocalAuthGuard);
//# sourceMappingURL=local-auth.guard.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"local-auth.guard.js","sourceRoot":"","sources":["../../../src/auth/guards/local-auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA8D;AAC9D,+CAA6C;AAGtC,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,IAAA,oBAAS,EAAC,OAAO,CAAC;IACpD,KAAK,CAAC,WAAW,CAAC,OAAyB;QACzC,MAAM,MAAM,GAAG,CAAC,MAAM,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAY,CAAC;QAC7D,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AAPY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;GACA,cAAc,CAO1B"}

11
dist/auth/local.strategy.d.ts vendored Normal file
View File

@@ -0,0 +1,11 @@
import { Strategy } from 'passport-local';
import { AuthService } from './auth.service';
declare const LocalStrategy_base: new (...args: [] | [options: import("passport-local").IStrategyOptionsWithRequest] | [options: import("passport-local").IStrategyOptions]) => Strategy & {
validate(...args: any[]): unknown;
};
export declare class LocalStrategy extends LocalStrategy_base {
private authService;
constructor(authService: AuthService);
validate(username: string, pass: string): Promise<any>;
}
export {};

35
dist/auth/local.strategy.js vendored Normal file
View File

@@ -0,0 +1,35 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocalStrategy = void 0;
const passport_local_1 = require("passport-local");
const passport_1 = require("@nestjs/passport");
const common_1 = require("@nestjs/common");
const auth_service_1 = require("./auth.service");
let LocalStrategy = class LocalStrategy extends (0, passport_1.PassportStrategy)(passport_local_1.Strategy) {
constructor(authService) {
super();
this.authService = authService;
}
async validate(username, pass) {
const user = await this.authService.validateUser(username, pass);
if (!user) {
throw new common_1.UnauthorizedException();
}
return user;
}
};
exports.LocalStrategy = LocalStrategy;
exports.LocalStrategy = LocalStrategy = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [auth_service_1.AuthService])
], LocalStrategy);
//# sourceMappingURL=local.strategy.js.map

1
dist/auth/local.strategy.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"local.strategy.js","sourceRoot":"","sources":["../../src/auth/local.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAA0C;AAC1C,+CAAoD;AACpD,2CAAmE;AACnE,iDAA6C;AAGtC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,IAAA,2BAAgB,EAAC,yBAAQ,CAAC;IAC3D,YAAoB,WAAwB;QAC1C,KAAK,EAAE,CAAC;QADU,gBAAW,GAAX,WAAW,CAAa;IAE5C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAgB,EAAE,IAAY;QAC3C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACjE,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACpC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAZY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAEsB,0BAAW;GADjC,aAAa,CAYzB"}

8
dist/auth/session.serializer.d.ts vendored Normal file
View File

@@ -0,0 +1,8 @@
import { PassportSerializer } from '@nestjs/passport';
import { UsersService } from '../users/users.service';
export declare class SessionSerializer extends PassportSerializer {
private readonly usersService;
constructor(usersService: UsersService);
serializeUser(user: any, done: Function): void;
deserializeUser(userId: any, done: Function): Promise<void>;
}

34
dist/auth/session.serializer.js vendored Normal file
View File

@@ -0,0 +1,34 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SessionSerializer = void 0;
const passport_1 = require("@nestjs/passport");
const common_1 = require("@nestjs/common");
const users_service_1 = require("../users/users.service");
let SessionSerializer = class SessionSerializer extends passport_1.PassportSerializer {
constructor(usersService) {
super();
this.usersService = usersService;
}
serializeUser(user, done) {
done(null, user.id);
}
async deserializeUser(userId, done) {
const user = await this.usersService.findById(userId);
done(null, user);
}
};
exports.SessionSerializer = SessionSerializer;
exports.SessionSerializer = SessionSerializer = __decorate([
(0, common_1.Injectable)(),
__metadata("design:paramtypes", [users_service_1.UsersService])
], SessionSerializer);
//# sourceMappingURL=session.serializer.js.map

1
dist/auth/session.serializer.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"session.serializer.js","sourceRoot":"","sources":["../../src/auth/session.serializer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAsD;AACtD,2CAA4C;AAC5C,0DAAsD;AAG/C,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,6BAAkB;IACvD,YAA6B,YAA0B;QACrD,KAAK,EAAE,CAAC;QADmB,iBAAY,GAAZ,YAAY,CAAc;IAEvD,CAAC;IAED,aAAa,CAAC,IAAS,EAAE,IAAc;QACrC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,MAAW,EAAE,IAAc;QAC/C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnB,CAAC;CACF,CAAA;AAbY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAEgC,4BAAY;GAD5C,iBAAiB,CAa7B"}

View File

@@ -0,0 +1,5 @@
import { NestMiddleware } from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';
export declare class LocalsMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: NextFunction): void;
}

View File

@@ -0,0 +1,26 @@
"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocalsMiddleware = void 0;
const common_1 = require("@nestjs/common");
let LocalsMiddleware = class LocalsMiddleware {
use(req, res, next) {
const reqAny = req;
res.locals.current_user = reqAny.user;
res.locals.success_msg = reqAny.flash('success_msg');
res.locals.error_msg = reqAny.flash('error_msg');
res.locals.error = reqAny.flash('error');
res.locals.path = req.path;
next();
}
};
exports.LocalsMiddleware = LocalsMiddleware;
exports.LocalsMiddleware = LocalsMiddleware = __decorate([
(0, common_1.Injectable)()
], LocalsMiddleware);
//# sourceMappingURL=locals.middleware.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"locals.middleware.js","sourceRoot":"","sources":["../../../src/common/middleware/locals.middleware.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4D;AAIrD,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,GAAG,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;QACjD,MAAM,MAAM,GAAG,GAAU,CAAC;QAC1B,GAAG,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC;QACtC,GAAG,CAAC,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACrD,GAAG,CAAC,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACjD,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACzC,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QAC3B,IAAI,EAAE,CAAC;IACT,CAAC;CACF,CAAA;AAVY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;GACA,gBAAgB,CAU5B"}

View File

@@ -0,0 +1,52 @@
import { UtilsService } from '../utils/utils.service';
import { UserGoal } from '../models/user-goal.model';
import { WeightLog } from '../models/weight-log.model';
import { Response } from 'express';
export declare class DashboardController {
private utilsService;
private userGoalModel;
private weightLogModel;
constructor(utilsService: UtilsService, userGoalModel: typeof UserGoal, weightLogModel: typeof WeightLog);
getDashboard(req: any, res: Response): Promise<{
user: any;
nutrition: {
calories: number;
protein: number;
carbs: number;
fat: number;
meals: any[];
};
water: {
total_ml: number;
logs: {
id: any;
amount_ml: number;
time: string;
}[];
};
goals: UserGoal;
weightLogToday: WeightLog;
weightChange: any;
remaining: {
calories: number;
protein: number;
carbs: number;
fat: number;
water: number;
};
macroPercentages: {
protein: number;
carbs: number;
fat: number;
};
} | {
user?: undefined;
nutrition?: undefined;
water?: undefined;
goals?: undefined;
weightLogToday?: undefined;
weightChange?: undefined;
remaining?: undefined;
macroPercentages?: undefined;
}>;
}

100
dist/dashboard/dashboard.controller.js vendored Normal file
View File

@@ -0,0 +1,100 @@
"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.DashboardController = 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");
const user_goal_model_1 = require("../models/user-goal.model");
const weight_log_model_1 = require("../models/weight-log.model");
const sequelize_1 = require("@nestjs/sequelize");
let DashboardController = class DashboardController {
constructor(utilsService, userGoalModel, weightLogModel) {
this.utilsService = utilsService;
this.userGoalModel = userGoalModel;
this.weightLogModel = weightLogModel;
}
async getDashboard(req, res) {
try {
const today = new Date();
const dateStr = today.toISOString().split('T')[0];
const nutrition = await this.utilsService.calculateDailyTotals(req.user.id, dateStr);
const water = await this.utilsService.calculateWaterTotal(req.user.id, dateStr);
let goals = await this.userGoalModel.findOne({ where: { UserId: req.user.id } });
if (!goals) {
goals = await this.userGoalModel.create({
UserId: req.user.id,
target_protein_g: 150,
target_carbs_g: 200,
target_fat_g: 60,
target_water_ml: 2000,
});
}
const weightLogToday = await this.weightLogModel.findOne({
where: { UserId: req.user.id, date: dateStr },
});
const yesterday = new Date(today);
yesterday.setDate(yesterday.getDate() - 1);
const yesterdayStr = yesterday.toISOString().split('T')[0];
const weightLogYesterday = await this.weightLogModel.findOne({
where: { UserId: req.user.id, date: yesterdayStr },
});
let weightChange = null;
if (weightLogToday && weightLogYesterday) {
weightChange = weightLogToday.weight_kg - weightLogYesterday.weight_kg;
}
const remaining = {
calories: req.user.target_daily_calories - nutrition.calories,
protein: goals.target_protein_g - nutrition.protein,
carbs: goals.target_carbs_g - nutrition.carbs,
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);
return {
user: req.user,
nutrition,
water,
goals,
weightLogToday,
weightChange,
remaining,
macroPercentages,
};
}
catch (err) {
console.error(err);
req.flash('error_msg', 'Error loading dashboard');
return {};
}
}
};
exports.DashboardController = DashboardController;
__decorate([
(0, common_1.Get)(),
(0, common_1.Render)('dashboard'),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise)
], DashboardController.prototype, "getDashboard", null);
exports.DashboardController = DashboardController = __decorate([
(0, common_1.Controller)('dashboard'),
(0, common_1.UseGuards)(authenticated_guard_1.AuthenticatedGuard),
__param(1, (0, sequelize_1.InjectModel)(user_goal_model_1.UserGoal)),
__param(2, (0, sequelize_1.InjectModel)(weight_log_model_1.WeightLog)),
__metadata("design:paramtypes", [utils_service_1.UtilsService, Object, Object])
], DashboardController);
//# sourceMappingURL=dashboard.controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"dashboard.controller.js","sourceRoot":"","sources":["../../src/dashboard/dashboard.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA8E;AAC9E,4EAAwE;AACxE,0DAAsD;AACtD,+DAAqD;AACrD,iEAAuD;AACvD,iDAAgD;AAKzC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,YACU,YAA0B,EACH,aAA8B,EAC7B,cAAgC;QAFxD,iBAAY,GAAZ,YAAY,CAAc;QACH,kBAAa,GAAb,aAAa,CAAiB;QAC7B,mBAAc,GAAd,cAAc,CAAkB;IAC/D,CAAC;IAIE,AAAN,KAAK,CAAC,YAAY,CAAQ,GAAG,EAAS,GAAa;QACjD,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,IAAI,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAGlD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;YACrF,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;YAGhF,IAAI,KAAK,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YACjF,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,KAAK,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;oBACtC,MAAM,EAAE,GAAG,CAAC,IAAI,CAA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CAAC,eAAe,GAAG,KAAK,CAAC,QAAQ;aAC9C,CAAC;YAGF,MAAM,gBAAgB,GAAG,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAC5D,SAAS,CAAC,OAAO,EACjB,SAAS,CAAC,KAAK,EACf,SAAS,CAAC,GAAG,CACd,CAAC;YAEF,OAAO;gBACL,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,SAAS;gBACT,KAAK;gBACL,KAAK;gBACL,cAAc;gBACd,YAAY;gBACZ,SAAS;gBACT,gBAAgB;aACjB,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,yBAAyB,CAAC,CAAC;YAUlD,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF,CAAA;AAzFY,kDAAmB;AASxB;IAFL,IAAA,YAAG,GAAE;IACL,IAAA,eAAM,EAAC,WAAW,CAAC;IACA,WAAA,IAAA,YAAG,GAAE,CAAA;IAAO,WAAA,IAAA,YAAG,GAAE,CAAA;;;;uDA+EpC;8BAxFU,mBAAmB;IAF/B,IAAA,mBAAU,EAAC,WAAW,CAAC;IACvB,IAAA,kBAAS,EAAC,wCAAkB,CAAC;IAIzB,WAAA,IAAA,uBAAW,EAAC,0BAAQ,CAAC,CAAA;IACrB,WAAA,IAAA,uBAAW,EAAC,4BAAS,CAAC,CAAA;qCAFD,4BAAY;GAFzB,mBAAmB,CAyF/B"}

2
dist/dashboard/dashboard.module.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare class DashboardModule {
}

29
dist/dashboard/dashboard.module.js vendored Normal file
View File

@@ -0,0 +1,29 @@
"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DashboardModule = void 0;
const common_1 = require("@nestjs/common");
const sequelize_1 = require("@nestjs/sequelize");
const dashboard_controller_1 = require("./dashboard.controller");
const progress_controller_1 = require("./progress.controller");
const user_goal_model_1 = require("../models/user-goal.model");
const weight_log_model_1 = require("../models/weight-log.model");
const utils_module_1 = require("../utils/utils.module");
let DashboardModule = class DashboardModule {
};
exports.DashboardModule = DashboardModule;
exports.DashboardModule = DashboardModule = __decorate([
(0, common_1.Module)({
imports: [
sequelize_1.SequelizeModule.forFeature([user_goal_model_1.UserGoal, weight_log_model_1.WeightLog]),
utils_module_1.UtilsModule,
],
controllers: [dashboard_controller_1.DashboardController, progress_controller_1.ProgressController],
})
], DashboardModule);
//# sourceMappingURL=dashboard.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"dashboard.module.js","sourceRoot":"","sources":["../../src/dashboard/dashboard.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iDAAoD;AACpD,iEAA6D;AAC7D,+DAA2D;AAC3D,+DAAqD;AACrD,iEAAuD;AACvD,wDAAoD;AAS7C,IAAM,eAAe,GAArB,MAAM,eAAe;CAAG,CAAA;AAAlB,0CAAe;0BAAf,eAAe;IAP3B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,2BAAe,CAAC,UAAU,CAAC,CAAC,0BAAQ,EAAE,4BAAS,CAAC,CAAC;YACjD,0BAAW;SACZ;QACD,WAAW,EAAE,CAAC,0CAAmB,EAAE,wCAAkB,CAAC;KACvD,CAAC;GACW,eAAe,CAAG"}

19
dist/dashboard/progress.controller.d.ts vendored Normal file
View File

@@ -0,0 +1,19 @@
import { UtilsService } from '../utils/utils.service';
export declare class ProgressController {
private utilsService;
constructor(utilsService: UtilsService);
getProgress(req: any, daysQuery: string): Promise<{
user: any;
weight_trend: {
date: Date;
weight_kg: number;
}[];
calorie_trend: any[];
avg_calories: number;
avg_protein: number;
avg_carbs: number;
avg_fat: number;
weight_change: any;
days: number;
}>;
}

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

View File

@@ -0,0 +1 @@
{"version":3,"file":"progress.controller.js","sourceRoot":"","sources":["../../src/dashboard/progress.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgF;AAChF,4EAAwE;AACxE,0DAAsD;AAI/C,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YAAoB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAI5C,AAAN,KAAK,CAAC,WAAW,CAAQ,GAAG,EAAiB,SAAiB;QAC5D,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;YAEvC,MAAM,WAAW,GAAG,MAAM,IAAI,C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

57
dist/database/database.module.js vendored Normal file
View File

@@ -0,0 +1,57 @@
"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatabaseModule = void 0;
const common_1 = require("@nestjs/common");
const sequelize_1 = require("@nestjs/sequelize");
const config_1 = require("@nestjs/config");
const user_model_1 = require("../models/user.model");
const food_item_model_1 = require("../models/food-item.model");
const meal_model_1 = require("../models/meal.model");
const meal_food_model_1 = require("../models/meal-food.model");
const water_log_model_1 = require("../models/water-log.model");
const weight_log_model_1 = require("../models/weight-log.model");
const meal_plan_model_1 = require("../models/meal-plan.model");
const planned_food_model_1 = require("../models/planned-food.model");
const user_goal_model_1 = require("../models/user-goal.model");
const daily_summary_model_1 = require("../models/daily-summary.model");
const api_cache_model_1 = require("../models/api-cache.model");
let DatabaseModule = class DatabaseModule {
};
exports.DatabaseModule = DatabaseModule;
exports.DatabaseModule = DatabaseModule = __decorate([
(0, common_1.Module)({
imports: [
sequelize_1.SequelizeModule.forRootAsync({
imports: [config_1.ConfigModule],
useFactory: (configService) => ({
dialect: 'sqlite',
storage: configService.get('DATABASE_URL') ? configService.get('DATABASE_URL').replace('sqlite://', '') : 'data/calorie_tracker.db',
models: [
user_model_1.User,
food_item_model_1.FoodItem,
meal_model_1.Meal,
meal_food_model_1.MealFood,
water_log_model_1.WaterLog,
weight_log_model_1.WeightLog,
meal_plan_model_1.MealPlan,
planned_food_model_1.PlannedFood,
user_goal_model_1.UserGoal,
daily_summary_model_1.DailySummary,
api_cache_model_1.APICache,
],
autoLoadModels: true,
synchronize: true,
logging: false,
}),
inject: [config_1.ConfigService],
}),
],
})
], DatabaseModule);
//# sourceMappingURL=database.module.js.map

1
dist/database/database.module.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"database.module.js","sourceRoot":"","sources":["../../src/database/database.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iDAAoD;AACpD,2CAA6D;AAC7D,qDAA4C;AAC5C,+DAAqD;AACrD,qDAA4C;AAC5C,+DAAqD;AACrD,+DAAqD;AACrD,iEAAuD;AACvD,+DAAqD;AACrD,qEAA2D;AAC3D,+DAAqD;AACrD,uEAA6D;AAC7D,+DAAqD;AA8B9C,IAAM,cAAc,GAApB,MAAM,cAAc;CAAG,CAAA;AAAjB,wCAAc;yBAAd,cAAc;IA5B1B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,2BAAe,CAAC,YAAY,CAAC;gBAC3B,OAAO,EAAE,CAAC,qBAAY,CAAC;gBACvB,UAAU,EAAE,CAAC,aAA4B,EAAE,EAAE,CAAC,CAAC;oBAC7C,OAAO,EAAE,QAAQ;oBACjB,OAAO,EAAE,aAAa,CAAC,GAAG,CAAS,cAAc,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAS,cAAc,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,yBAAyB;oBACnJ,MAAM,EAAE;wBACN,iBAAI;wBACJ,0BAAQ;wBACR,iBAAI;wBACJ,0BAAQ;wBACR,0BAAQ;wBACR,4BAAS;wBACT,0BAAQ;wBACR,gCAAW;wBACX,0BAAQ;wBACR,kCAAY;wBACZ,0BAAQ;qBACT;oBACD,cAAc,EAAE,IAAI;oBACpB,WAAW,EAAE,IAAI;oBACjB,OAAO,EAAE,KAAK;iBACf,CAAC;gBACF,MAAM,EAAE,CAAC,sBAAa,CAAC;aACxB,CAAC;SACH;KACF,CAAC;GACW,cAAc,CAAG"}

13
dist/foods/foods.controller.d.ts vendored Normal file
View File

@@ -0,0 +1,13 @@
import { FoodsService } from './foods.service';
export declare class FoodsController {
private foodsService;
constructor(foodsService: FoodsService);
getFoods(req: any, category: string, q: string): Promise<{
filipino_foods: import("../models/food-item.model").FoodItem[];
other_foods: import("../models/food-item.model").FoodItem[];
categories: string[];
current_category: string;
search_query: string;
user: any;
}>;
}

58
dist/foods/foods.controller.js vendored Normal file
View File

@@ -0,0 +1,58 @@
"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.FoodsController = void 0;
const common_1 = require("@nestjs/common");
const authenticated_guard_1 = require("../auth/guards/authenticated.guard");
const foods_service_1 = require("./foods.service");
let FoodsController = class FoodsController {
constructor(foodsService) {
this.foodsService = foodsService;
}
async getFoods(req, category, q) {
try {
const data = await this.foodsService.getFoods(category, q);
return Object.assign({ user: req.user }, data);
}
catch (err) {
console.error(err);
req.flash('error_msg', 'Error loading foods');
return {
user: req.user,
filipino_foods: [],
other_foods: [],
categories: [],
current_category: 'all',
search_query: '',
};
}
}
};
exports.FoodsController = FoodsController;
__decorate([
(0, common_1.Get)(),
(0, common_1.Render)('foods'),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Query)('category')),
__param(2, (0, common_1.Query)('q')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String, String]),
__metadata("design:returntype", Promise)
], FoodsController.prototype, "getFoods", null);
exports.FoodsController = FoodsController = __decorate([
(0, common_1.Controller)('foods'),
(0, common_1.UseGuards)(authenticated_guard_1.AuthenticatedGuard),
__metadata("design:paramtypes", [foods_service_1.FoodsService])
], FoodsController);
//# sourceMappingURL=foods.controller.js.map

1
dist/foods/foods.controller.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"foods.controller.js","sourceRoot":"","sources":["../../src/foods/foods.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAgF;AAChF,4EAAwE;AACxE,mDAA+C;AAIxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAAoB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAI5C,AAAN,KAAK,CAAC,QAAQ,CAAQ,GAAG,EAAqB,QAAgB,EAAc,CAAS;QACnF,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;YAC3D,uBACE,IAAI,EAAE,GAAG,CAAC,IAAI,IACX,IAAI,EACP;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC;YAC9C,OAAO;gBACL,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,cAAc,EAAE,EAAE;gBAClB,WAAW,EAAE,EAAE;gBACf,UAAU,EAAE,EAAE;gBACd,gBAAgB,EAAE,KAAK;gBACvB,YAAY,EAAE,EAAE;aACjB,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AAzBY,0CAAe;AAKpB;IAFL,IAAA,YAAG,GAAE;IACL,IAAA,eAAM,EAAC,OAAO,CAAC;IACA,WAAA,IAAA,YAAG,GAAE,CAAA;IAAO,WAAA,IAAA,cAAK,EAAC,UAAU,CAAC,CAAA;IAAoB,WAAA,IAAA,cAAK,EAAC,GAAG,CAAC,CAAA;;;;+CAmB1E;0BAxBU,eAAe;IAF3B,IAAA,mBAAU,EAAC,OAAO,CAAC;IACnB,IAAA,kBAAS,EAAC,wCAAkB,CAAC;qCAEM,4BAAY;GADnC,eAAe,CAyB3B"}

2
dist/foods/foods.module.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare class FoodsModule {
}

25
dist/foods/foods.module.js vendored Normal file
View File

@@ -0,0 +1,25 @@
"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FoodsModule = void 0;
const common_1 = require("@nestjs/common");
const sequelize_1 = require("@nestjs/sequelize");
const foods_controller_1 = require("./foods.controller");
const foods_service_1 = require("./foods.service");
const food_item_model_1 = require("../models/food-item.model");
let FoodsModule = class FoodsModule {
};
exports.FoodsModule = FoodsModule;
exports.FoodsModule = FoodsModule = __decorate([
(0, common_1.Module)({
imports: [sequelize_1.SequelizeModule.forFeature([food_item_model_1.FoodItem])],
controllers: [foods_controller_1.FoodsController],
providers: [foods_service_1.FoodsService],
})
], FoodsModule);
//# sourceMappingURL=foods.module.js.map

1
dist/foods/foods.module.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"foods.module.js","sourceRoot":"","sources":["../../src/foods/foods.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iDAAoD;AACpD,yDAAqD;AACrD,mDAA+C;AAC/C,+DAAqD;AAO9C,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IALvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,2BAAe,CAAC,UAAU,CAAC,CAAC,0BAAQ,CAAC,CAAC,CAAC;QACjD,WAAW,EAAE,CAAC,kCAAe,CAAC;QAC9B,SAAS,EAAE,CAAC,4BAAY,CAAC;KAC1B,CAAC;GACW,WAAW,CAAG"}

12
dist/foods/foods.service.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
import { FoodItem } from '../models/food-item.model';
export declare class FoodsService {
private foodItemModel;
constructor(foodItemModel: typeof FoodItem);
getFoods(category?: string, searchQuery?: string): Promise<{
filipino_foods: FoodItem[];
other_foods: FoodItem[];
categories: string[];
current_category: string;
search_query: string;
}>;
}

62
dist/foods/foods.service.js vendored Normal file
View File

@@ -0,0 +1,62 @@
"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.FoodsService = void 0;
const common_1 = require("@nestjs/common");
const sequelize_1 = require("@nestjs/sequelize");
const sequelize_2 = require("sequelize");
const food_item_model_1 = require("../models/food-item.model");
let FoodsService = class FoodsService {
constructor(foodItemModel) {
this.foodItemModel = foodItemModel;
}
async getFoods(category = 'all', searchQuery = '') {
const whereClause = {};
if (category !== 'all') {
whereClause.category = category;
}
if (searchQuery) {
whereClause[sequelize_2.Op.or] = [
{ name: { [sequelize_2.Op.like]: `%${searchQuery}%` } },
{ name_tagalog: { [sequelize_2.Op.like]: `%${searchQuery}%` } },
];
}
const filipinoWhere = Object.assign(Object.assign({}, whereClause), { is_filipino: true });
const otherWhere = Object.assign(Object.assign({}, whereClause), { is_filipino: false });
const filipinoFoods = await this.foodItemModel.findAll({
where: filipinoWhere,
order: [['name', 'ASC']],
});
const otherFoods = await this.foodItemModel.findAll({
where: otherWhere,
limit: 20,
order: [['name', 'ASC']],
});
const categories = ['all', 'kanin', 'ulam', 'sabaw', 'gulay', 'meryenda', 'almusal'];
return {
filipino_foods: filipinoFoods,
other_foods: otherFoods,
categories,
current_category: category,
search_query: searchQuery,
};
}
};
exports.FoodsService = FoodsService;
exports.FoodsService = FoodsService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, sequelize_1.InjectModel)(food_item_model_1.FoodItem)),
__metadata("design:paramtypes", [Object])
], FoodsService);
//# sourceMappingURL=foods.service.js.map

1
dist/foods/foods.service.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"foods.service.js","sourceRoot":"","sources":["../../src/foods/foods.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,iDAAgD;AAChD,yCAA+B;AAC/B,+DAAqD;AAG9C,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YACiC,aAA8B;QAA9B,kBAAa,GAAb,aAAa,CAAiB;IAC5D,CAAC;IAEJ,KAAK,CAAC,QAAQ,CAAC,WAAmB,KAAK,EAAE,cAAsB,EAAE;QAC/D,MAAM,WAAW,GAAQ,EAAE,CAAC;QAE5B,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;YACvB,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAClC,CAAC;QAED,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View File

@@ -0,0 +1,13 @@
import { Response } from 'express';
import { GoalsService } from './goals.service';
export declare class GoalsController {
private goalsService;
constructor(goalsService: GoalsService);
getGoals(req: any): Promise<{
user: any;
goals: import("../models/user-goal.model").UserGoal;
bmr: any;
tdee: any;
}>;
updateGoals(req: any, body: any, res: Response): Promise<void>;
}

80
dist/goals/goals.controller.js vendored Normal file
View File

@@ -0,0 +1,80 @@
"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

1
dist/goals/goals.controller.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"goals.controller.js","sourceRoot":"","sources":["../../src/goals/goals.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0F;AAE1F,4EAAwE;AACxE,mDAA+C;AAIxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC1B,YAAoB,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAI5C,AAAN,KAAK,CAAC,QAAQ,CAAQ,GAAG;QACvB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3D,OAAO;gBACL,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,qBAAqB,CAAC,CAAC;YAC9C,OAAO;gBACL,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,KAAK,EAAE,IAAI;gBACX,GAAG,EAAE,IAAI;gBACT,IAAI,EAAE,IAAI;aACX,CAAC;QACJ,CAAC;IACH,CAAC;IAGK,AAAN,KAAK,CAAC,WAAW,CAAQ,GAAG,EAAU,IAAI,EAAS,GAAa;QAC9D,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;YACvD,GAAG,CAAC,KAAK,CAAC,aAAa,EAAE,6BAA6B,CAAC,CAAC;YACxD,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAC;YAC/C,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;CACF,CAAA;AAtCY,0CAAe;AAKpB;IAFL,IAAA,YAAG,GAAE;IACL,IAAA,eAAM,EAAC,OAAO,CAAC;IACA,WAAA,IAAA,YAAG,GAAE,CAAA;;;;+CAmBpB;AAGK;IADL,IAAA,aAAI,GAAE;IACY,WAAA,IAAA,YAAG,GAAE,CAAA;IAAO,WAAA,IAAA,aAAI,GAAE,CAAA;IAAQ,WAAA,IAAA,YAAG,GAAE,CAAA;;;;kDAUjD;0BArCU,eAAe;IAF3B,IAAA,mBAAU,EAAC,OAAO,CAAC;IACnB,IAAA,kBAAS,EAAC,wCAAkB,CAAC;qCAEM,4BAAY;GADnC,eAAe,CAsC3B"}

2
dist/goals/goals.module.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare class GoalsModule {
}

30
dist/goals/goals.module.js vendored Normal file
View File

@@ -0,0 +1,30 @@
"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GoalsModule = void 0;
const common_1 = require("@nestjs/common");
const sequelize_1 = require("@nestjs/sequelize");
const goals_controller_1 = require("./goals.controller");
const goals_service_1 = require("./goals.service");
const user_model_1 = require("../models/user.model");
const user_goal_model_1 = require("../models/user-goal.model");
const utils_module_1 = require("../utils/utils.module");
let GoalsModule = class GoalsModule {
};
exports.GoalsModule = GoalsModule;
exports.GoalsModule = GoalsModule = __decorate([
(0, common_1.Module)({
imports: [
sequelize_1.SequelizeModule.forFeature([user_model_1.User, user_goal_model_1.UserGoal]),
utils_module_1.UtilsModule,
],
controllers: [goals_controller_1.GoalsController],
providers: [goals_service_1.GoalsService],
})
], GoalsModule);
//# sourceMappingURL=goals.module.js.map

1
dist/goals/goals.module.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"goals.module.js","sourceRoot":"","sources":["../../src/goals/goals.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iDAAoD;AACpD,yDAAqD;AACrD,mDAA+C;AAC/C,qDAA4C;AAC5C,+DAAqD;AACrD,wDAAoD;AAU7C,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IARvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,2BAAe,CAAC,UAAU,CAAC,CAAC,iBAAI,EAAE,0BAAQ,CAAC,CAAC;YAC5C,0BAAW;SACZ;QACD,WAAW,EAAE,CAAC,kCAAe,CAAC;QAC9B,SAAS,EAAE,CAAC,4BAAY,CAAC;KAC1B,CAAC;GACW,WAAW,CAAG"}

20
dist/goals/goals.service.d.ts vendored Normal file
View File

@@ -0,0 +1,20 @@
import { User } from '../models/user.model';
import { UserGoal } from '../models/user-goal.model';
import { UtilsService } from '../utils/utils.service';
export declare class GoalsService {
private userModel;
private userGoalModel;
private utilsService;
constructor(userModel: typeof User, userGoalModel: typeof UserGoal, utilsService: UtilsService);
getGoals(userId: number): Promise<{
goals: UserGoal;
bmr: any;
tdee: any;
user: User;
}>;
updateGoals(userId: number, data: any): Promise<{
success: boolean;
user: User;
goals: UserGoal;
}>;
}

94
dist/goals/goals.service.js vendored Normal file
View File

@@ -0,0 +1,94 @@
"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.GoalsService = void 0;
const common_1 = require("@nestjs/common");
const sequelize_1 = require("@nestjs/sequelize");
const user_model_1 = require("../models/user.model");
const user_goal_model_1 = require("../models/user-goal.model");
const utils_service_1 = require("../utils/utils.service");
let GoalsService = class GoalsService {
constructor(userModel, userGoalModel, utilsService) {
this.userModel = userModel;
this.userGoalModel = userGoalModel;
this.utilsService = utilsService;
}
async getGoals(userId) {
const user = await this.userModel.findByPk(userId);
const userGoals = await this.userGoalModel.findOne({ where: { UserId: userId } });
let bmr = null;
let tdee = null;
if (user && user.weight_kg && user.height_cm && user.age) {
bmr = this.utilsService.calculateBMR(user.weight_kg, user.height_cm, user.age, user.gender || 'male');
tdee = this.utilsService.calculateTDEE(bmr, user.activity_level || 'moderate');
}
return {
goals: userGoals,
bmr,
tdee,
user,
};
}
async updateGoals(userId, data) {
const user = await this.userModel.findByPk(userId);
if (!user) {
throw new Error('User not found');
}
user.age = parseInt(data.age) || 25;
user.gender = data.gender || 'male';
user.height_cm = parseFloat(data.height_cm) || 170;
user.weight_kg = parseFloat(data.weight_kg) || 70;
user.activity_level = data.activity_level || 'moderate';
const bmr = this.utilsService.calculateBMR(user.weight_kg, user.height_cm, user.age, user.gender);
const tdee = this.utilsService.calculateTDEE(bmr, user.activity_level);
const goalType = data.goal_type || 'recomp';
let targetCalories;
if (goalType === 'weight_loss') {
targetCalories = tdee - 500;
}
else if (goalType === 'muscle_gain') {
targetCalories = tdee + 300;
}
else {
targetCalories = tdee;
}
user.target_daily_calories = Math.round(targetCalories);
await user.save();
let userGoals = await this.userGoalModel.findOne({ where: { UserId: userId } });
if (!userGoals) {
userGoals = await this.userGoalModel.create({ UserId: userId });
}
userGoals.goal_type = goalType;
userGoals.target_weight_kg = parseFloat(data.target_weight_kg) || 70;
const macros = this.utilsService.calculateMacroTargets(user.weight_kg, goalType);
userGoals.target_protein_g = macros.protein_g;
userGoals.target_carbs_g = macros.carbs_g;
userGoals.target_fat_g = macros.fat_g;
userGoals.target_water_ml = parseInt(data.target_water_ml) || 2000;
await userGoals.save();
return {
success: true,
user,
goals: userGoals,
};
}
};
exports.GoalsService = GoalsService;
exports.GoalsService = GoalsService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, sequelize_1.InjectModel)(user_model_1.User)),
__param(1, (0, sequelize_1.InjectModel)(user_goal_model_1.UserGoal)),
__metadata("design:paramtypes", [Object, Object, utils_service_1.UtilsService])
], GoalsService);
//# sourceMappingURL=goals.service.js.map

1
dist/goals/goals.service.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"goals.service.js","sourceRoot":"","sources":["../../src/goals/goals.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,iDAAgD;AAChD,qDAA4C;AAC5C,+DAAqD;AACrD,0DAAsD;AAG/C,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAC6B,SAAsB,EAClB,aAA8B,EACrD,YAA0B;QAFP,cAAS,GAAT,SAAS,CAAa;QAClB,kBAAa,GAAb,aAAa,CAAiB;QACrD,iBAAY,GAAZ,YAAY,CAAc;IACjC,CAAC;IAEJ,KAAK,CAAC,QAAQ,CAAC,MAAc;QAC3B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACnD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QAElF,IAAI,GAAG,GAAG,IAAI,CAAC;QACf,IAAI,IAAI,GAAG,IAAI,CAAC;QAEhB,IAAI,IAAI,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACzD,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAClC,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,MAAM,IAAI,MAAM,CACtB,CAAC;YACF,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,cAAc,IAAI,UAAU,CAAC,CAAC;QACjF,CAAC;QAED,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,GAAG;YACH,IAAI;YACJ,IAAI;SACL,CAAC;IACJ,CAAC;IAED,KA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al file
View File

@@ -0,0 +1 @@
export {};

38
dist/main.js vendored Normal file
View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@nestjs/core");
const app_module_1 = require("./app.module");
const session = require("express-session");
const passport = require("passport");
const flash = require("express-flash");
const expressLayouts = require("express-ejs-layouts");
const methodOverride = require("method-override");
const path = require("path");
const SQLiteStore = require('connect-sqlite3')(session);
async function bootstrap() {
const app = await core_1.NestFactory.create(app_module_1.AppModule);
app.useStaticAssets(path.join(__dirname, '..', 'public'));
app.setBaseViewsDir(path.join(__dirname, '..', 'views'));
app.setViewEngine('ejs');
app.use(expressLayouts);
app.set('layout', 'layout');
app.use(methodOverride('_method'));
app.useBodyParser('urlencoded', { extended: true });
app.use(session({
store: new SQLiteStore({ db: 'sessions.db', dir: './data' }),
secret: process.env.SECRET_KEY || 'secret',
resave: false,
saveUninitialized: false,
cookie: { maxAge: 30 * 24 * 60 * 60 * 1000 },
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
const expressApp = app.getHttpAdapter().getInstance();
expressApp.locals.round = Math.round;
const PORT = process.env.PORT || 3000;
await app.listen(PORT);
console.log(`Application is running on: ${await app.getUrl()}`);
}
bootstrap();
//# sourceMappingURL=main.js.map

1
dist/main.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAE3C,6CAAyC;AACzC,2CAA2C;AAC3C,qCAAqC;AACrC,uCAAuC;AACvC,sDAAsD;AACtD,kDAAkD;AAClD,6BAA6B;AAG7B,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC;AAExD,KAAK,UAAU,SAAS;IACtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAyB,sBAAS,CAAC,CAAC;IAGxE,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CA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,IAAI,CAAC;IACtC,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACvB,OAAO,CAAC,GAAG,CAAC,8BAA8B,MAAM,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAClE,CAAC;AACD,SAAS,EAAE,CAAC"}

View File

@@ -0,0 +1,15 @@
import { Response } from 'express';
import { MealPlannerService } from './meal-planner.service';
export declare class MealPlannerController {
private mealPlannerService;
constructor(mealPlannerService: MealPlannerService);
getMealPlanner(req: any): Promise<{
user: any;
dates: any[];
meal_plans: {};
today: string;
}>;
autoGenerate(req: any, body: any, res: Response): Promise<void>;
addMealPlan(req: any, body: any, res: Response): Promise<void>;
toggleComplete(req: any, id: number, res: Response): Promise<void>;
}

View File

@@ -0,0 +1,125 @@
"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.MealPlannerController = void 0;
const common_1 = require("@nestjs/common");
const authenticated_guard_1 = require("../auth/guards/authenticated.guard");
const meal_planner_service_1 = require("./meal-planner.service");
let MealPlannerController = class MealPlannerController {
constructor(mealPlannerService) {
this.mealPlannerService = mealPlannerService;
}
async getMealPlanner(req) {
try {
const data = await this.mealPlannerService.getWeeklyMealPlans(req.user.id);
return {
user: req.user,
dates: data.dates,
meal_plans: data.mealPlans,
today: data.today,
};
}
catch (err) {
console.error(err);
req.flash('error_msg', 'Error loading meal planner');
return {
user: req.user,
dates: [],
meal_plans: {},
today: new Date().toISOString().split('T')[0],
};
}
}
async autoGenerate(req, body, res) {
try {
const { date } = body;
if (!date) {
req.flash('error_msg', 'Please select a date');
return res.redirect('/meal-planner');
}
await this.mealPlannerService.autoGenerate(req.user.id, date);
req.flash('success_msg', 'Meal plan generated successfully!');
res.redirect('/meal-planner');
}
catch (err) {
console.error(err);
req.flash('error_msg', 'Error generating meal plan');
res.redirect('/meal-planner');
}
}
async addMealPlan(req, body, res) {
try {
await this.mealPlannerService.addMealPlan(req.user.id, body);
req.flash('success_msg', 'Meal plan updated!');
res.redirect('/meal-planner');
}
catch (err) {
console.error(err);
req.flash('error_msg', 'Error adding meal plan');
res.redirect('/meal-planner');
}
}
async toggleComplete(req, id, res) {
try {
await this.mealPlannerService.toggleComplete(req.user.id, id);
res.json({ success: true });
}
catch (err) {
console.error(err);
res.status(500).json({ success: false });
}
}
};
exports.MealPlannerController = MealPlannerController;
__decorate([
(0, common_1.Get)(),
(0, common_1.Render)('meal_planner'),
__param(0, (0, common_1.Req)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], MealPlannerController.prototype, "getMealPlanner", null);
__decorate([
(0, common_1.Post)('auto-generate'),
__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)
], MealPlannerController.prototype, "autoGenerate", null);
__decorate([
(0, common_1.Post)('add'),
__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)
], MealPlannerController.prototype, "addMealPlan", null);
__decorate([
(0, common_1.Post)('complete/:id'),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Param)('id')),
__param(2, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Number, Object]),
__metadata("design:returntype", Promise)
], MealPlannerController.prototype, "toggleComplete", null);
exports.MealPlannerController = MealPlannerController = __decorate([
(0, common_1.Controller)('meal-planner'),
(0, common_1.UseGuards)(authenticated_guard_1.AuthenticatedGuard),
__metadata("design:paramtypes", [meal_planner_service_1.MealPlannerService])
], MealPlannerController);
//# sourceMappingURL=meal-planner.controller.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"meal-planner.controller.js","sourceRoot":"","sources":["../../src/meal-planner/meal-planner.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAiG;AAEjG,4EAAwE;AACxE,iEAA4D;AAIrD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,YAAoB,kBAAsC;QAAtC,uBAAkB,GAAlB,kBAAkB,CAAoB;IAAG,CAAC;IAIxD,AAAN,KAAK,CAAC,cAAc,CAAQ,GAAG;QAC7B,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3E,OAAO;gBACL,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,UAAU,EAAE,IAAI,CAAC,SAAS;gBAC1B,KAAK,EAAE,IAAI,CAAC,KAAK;aAClB,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,4BAA4B,CAAC,CAAC;YACrD,OAAO;gBACL,IAAI,EAAE,GAAG,CAAC,IAAI;gBACd,KAAK,EAAE,EAAE;gBACT,UAAU,EAAE,EAAE;gBACd,KAAK,EAAE,IAAI,IAAI,EA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AAG,GAAE,CAAA;;;;2DAQ/D;gCAnEU,qBAAqB;IAFjC,IAAA,mBAAU,EAAC,cAAc,CAAC;IAC1B,IAAA,kBAAS,EAAC,wCAAkB,CAAC;qCAEY,yCAAkB;GAD/C,qBAAqB,CAoEjC"}

View File

@@ -0,0 +1,2 @@
export declare class MealPlannerModule {
}

View File

@@ -0,0 +1,31 @@
"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MealPlannerModule = void 0;
const common_1 = require("@nestjs/common");
const sequelize_1 = require("@nestjs/sequelize");
const meal_planner_controller_1 = require("./meal-planner.controller");
const meal_planner_service_1 = require("./meal-planner.service");
const meal_plan_model_1 = require("../models/meal-plan.model");
const planned_food_model_1 = require("../models/planned-food.model");
const food_item_model_1 = require("../models/food-item.model");
const utils_module_1 = require("../utils/utils.module");
let MealPlannerModule = class MealPlannerModule {
};
exports.MealPlannerModule = MealPlannerModule;
exports.MealPlannerModule = MealPlannerModule = __decorate([
(0, common_1.Module)({
imports: [
sequelize_1.SequelizeModule.forFeature([meal_plan_model_1.MealPlan, planned_food_model_1.PlannedFood, food_item_model_1.FoodItem]),
utils_module_1.UtilsModule,
],
controllers: [meal_planner_controller_1.MealPlannerController],
providers: [meal_planner_service_1.MealPlannerService],
})
], MealPlannerModule);
//# sourceMappingURL=meal-planner.module.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"meal-planner.module.js","sourceRoot":"","sources":["../../src/meal-planner/meal-planner.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iDAAoD;AACpD,uEAAkE;AAClE,iEAA4D;AAC5D,+DAAqD;AACrD,qEAA2D;AAC3D,+DAAqD;AACrD,wDAAoD;AAU7C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,8CAAiB;4BAAjB,iBAAiB;IAR7B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,2BAAe,CAAC,UAAU,CAAC,CAAC,0BAAQ,EAAE,gCAAW,EAAE,0BAAQ,CAAC,CAAC;YAC7D,0BAAW;SACZ;QACD,WAAW,EAAE,CAAC,+CAAqB,CAAC;QACpC,SAAS,EAAE,CAAC,yCAAkB,CAAC;KAChC,CAAC;GACW,iBAAiB,CAAG"}

View File

@@ -0,0 +1,19 @@
import { MealPlan } from '../models/meal-plan.model';
import { PlannedFood } from '../models/planned-food.model';
import { FoodItem } from '../models/food-item.model';
import { UtilsService } from '../utils/utils.service';
export declare class MealPlannerService {
private mealPlanModel;
private plannedFoodModel;
private foodItemModel;
private utilsService;
constructor(mealPlanModel: typeof MealPlan, plannedFoodModel: typeof PlannedFood, foodItemModel: typeof FoodItem, utilsService: UtilsService);
getWeeklyMealPlans(userId: number): Promise<{
dates: any[];
mealPlans: {};
today: string;
}>;
autoGenerate(userId: number, date: string): Promise<boolean>;
addMealPlan(userId: number, data: any): Promise<MealPlan>;
toggleComplete(userId: number, planId: number): Promise<MealPlan>;
}

View File

@@ -0,0 +1,150 @@
"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.MealPlannerService = void 0;
const common_1 = require("@nestjs/common");
const sequelize_1 = require("@nestjs/sequelize");
const meal_plan_model_1 = require("../models/meal-plan.model");
const planned_food_model_1 = require("../models/planned-food.model");
const food_item_model_1 = require("../models/food-item.model");
const utils_service_1 = require("../utils/utils.service");
let MealPlannerService = class MealPlannerService {
constructor(mealPlanModel, plannedFoodModel, foodItemModel, utilsService) {
this.mealPlanModel = mealPlanModel;
this.plannedFoodModel = plannedFoodModel;
this.foodItemModel = foodItemModel;
this.utilsService = utilsService;
}
async getWeeklyMealPlans(userId) {
const today = new Date();
const day = today.getDay();
const diff = today.getDate() - day + (day === 0 ? -6 : 1);
const startDate = new Date(today);
startDate.setDate(diff);
const dates = [];
for (let i = 0; i < 7; i++) {
const d = new Date(startDate);
d.setDate(startDate.getDate() + i);
dates.push(d);
}
const mealPlans = {};
for (const d of dates) {
const dateStr = d.toISOString().split('T')[0];
const plans = await this.mealPlanModel.findAll({
where: { UserId: userId, date: dateStr },
include: [
{
model: planned_food_model_1.PlannedFood,
include: [food_item_model_1.FoodItem],
},
],
});
mealPlans[dateStr] = plans.map((p) => {
let calories = 0, protein = 0, carbs = 0, fat = 0;
const foods = [];
if (p.plannedFoods) {
p.plannedFoods.forEach((pf) => {
if (pf.foodItem) {
const q = pf.quantity || 1;
calories += pf.foodItem.calories * q;
protein += pf.foodItem.protein_g * q;
carbs += pf.foodItem.carbs_g * q;
fat += pf.foodItem.fat_g * q;
foods.push({
name: pf.foodItem.name,
quantity: q,
});
}
});
}
return {
id: p.id,
meal_type: p.meal_type,
is_completed: p.is_completed,
foods: foods,
totals: {
calories,
protein,
carbs,
fat,
},
};
});
}
return {
dates: dates.map((d) => d.toISOString().split('T')[0]),
mealPlans,
today: new Date().toISOString().split('T')[0],
};
}
async autoGenerate(userId, date) {
return this.utilsService.generateDailyMealPlan(userId, date);
}
async addMealPlan(userId, data) {
let { date, meal_type, 'food_id[]': foodIds, 'quantity[]': quantities } = data;
if (!foodIds) {
throw new Error('Please add at least one food item');
}
if (!Array.isArray(foodIds)) {
foodIds = [foodIds];
quantities = [quantities];
}
let mealPlan = await this.mealPlanModel.findOne({
where: {
UserId: userId,
date: date,
meal_type: meal_type,
},
});
if (!mealPlan) {
mealPlan = await this.mealPlanModel.create({
UserId: userId,
date: date,
meal_type: meal_type,
});
}
for (let i = 0; i < foodIds.length; i++) {
const foodId = foodIds[i];
const quantity = quantities[i];
if (foodId && quantity) {
await this.plannedFoodModel.create({
MealPlanId: mealPlan.id,
FoodItemId: foodId,
quantity: quantity,
});
}
}
return mealPlan;
}
async toggleComplete(userId, planId) {
const plan = await this.mealPlanModel.findOne({
where: { id: planId, UserId: userId },
});
if (plan) {
plan.is_completed = !plan.is_completed;
await plan.save();
return plan;
}
return null;
}
};
exports.MealPlannerService = MealPlannerService;
exports.MealPlannerService = MealPlannerService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, sequelize_1.InjectModel)(meal_plan_model_1.MealPlan)),
__param(1, (0, sequelize_1.InjectModel)(planned_food_model_1.PlannedFood)),
__param(2, (0, sequelize_1.InjectModel)(food_item_model_1.FoodItem)),
__metadata("design:paramtypes", [Object, Object, Object, utils_service_1.UtilsService])
], MealPlannerService);
//# sourceMappingURL=meal-planner.service.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"meal-planner.service.js","sourceRoot":"","sources":["../../src/meal-planner/meal-planner.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,iDAAgD;AAChD,+DAAqD;AACrD,qEAA2D;AAC3D,+DAAqD;AACrD,0DAAsD;AAG/C,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,YACiC,aAA8B,EAC3B,gBAAoC,EACvC,aAA8B,EAC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normal file
View File

@@ -0,0 +1,32 @@
import { Response } from 'express';
import { UtilsService } from '../utils/utils.service';
import { NutritionService } from './nutrition.service';
import { Meal } from '../models/meal.model';
import { MealFood } from '../models/meal-food.model';
import { FoodItem } from '../models/food-item.model';
import { WaterLog } from '../models/water-log.model';
import { WeightLog } from '../models/weight-log.model';
export declare class MealsController {
private utilsService;
private nutritionService;
private mealModel;
private mealFoodModel;
private foodItemModel;
private waterLogModel;
private weightLogModel;
constructor(utilsService: UtilsService, nutritionService: NutritionService, mealModel: typeof Meal, mealFoodModel: typeof MealFood, foodItemModel: typeof FoodItem, waterLogModel: typeof WaterLog, weightLogModel: typeof WeightLog);
addMealPage(req: any, res: Response): void;
addMeal(req: any, res: Response, body: any): Promise<void>;
searchFood(query: string): Promise<any[]>;
addFood(body: any): Promise<{
success: boolean;
food_id: any;
name: string;
} | {
success: boolean;
food_id?: undefined;
name?: undefined;
}>;
addWater(req: any, res: Response, body: any): Promise<void>;
addWeight(req: any, res: Response, body: any): Promise<void>;
}

220
dist/meals/meals.controller.js vendored Normal file
View File

@@ -0,0 +1,220 @@
"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.MealsController = void 0;
const common_1 = require("@nestjs/common");
const sequelize_1 = require("@nestjs/sequelize");
const authenticated_guard_1 = require("../auth/guards/authenticated.guard");
const utils_service_1 = require("../utils/utils.service");
const nutrition_service_1 = require("./nutrition.service");
const meal_model_1 = require("../models/meal.model");
const meal_food_model_1 = require("../models/meal-food.model");
const food_item_model_1 = require("../models/food-item.model");
const water_log_model_1 = require("../models/water-log.model");
const weight_log_model_1 = require("../models/weight-log.model");
let MealsController = class MealsController {
constructor(utilsService, nutritionService, mealModel, mealFoodModel, foodItemModel, waterLogModel, weightLogModel) {
this.utilsService = utilsService;
this.nutritionService = nutritionService;
this.mealModel = mealModel;
this.mealFoodModel = mealFoodModel;
this.foodItemModel = foodItemModel;
this.waterLogModel = waterLogModel;
this.weightLogModel = weightLogModel;
}
addMealPage(req, res) {
res.render('add_meal', { today: new Date().toISOString().split('T')[0] });
}
async addMeal(req, res, body) {
try {
let { date, meal_type, time, 'food_id[]': foodIds, 'quantity[]': quantities } = body;
if (!foodIds) {
req.flash('error_msg', 'Please add at least one food item');
return res.redirect('/add-meal');
}
if (!Array.isArray(foodIds)) {
foodIds = [foodIds];
quantities = [quantities];
}
const meal = await this.mealModel.create({
UserId: req.user.id,
date: date || new Date(),
meal_type,
time: time || null,
});
for (let i = 0; i < foodIds.length; i++) {
const foodId = foodIds[i];
const quantity = quantities[i];
if (foodId && quantity) {
const food = await this.foodItemModel.findByPk(foodId);
if (food) {
await this.mealFoodModel.create({
MealId: meal.id,
FoodItemId: foodId,
quantity: quantity,
calories_consumed: food.calories * quantity,
protein_consumed: food.protein_g * quantity,
carbs_consumed: food.carbs_g * quantity,
fat_consumed: food.fat_g * quantity,
});
}
}
}
await this.utilsService.updateDailySummary(req.user.id, date);
req.flash('success_msg', 'Meal added successfully!');
res.redirect('/dashboard');
}
catch (err) {
console.error(err);
req.flash('error_msg', 'Error adding meal');
res.redirect('/add-meal');
}
}
async searchFood(query) {
if (!query || query.length < 2) {
return [];
}
return this.nutritionService.searchAllSources(query);
}
async addFood(body) {
try {
const food = await this.nutritionService.saveFoodToDb(body);
if (food) {
return {
success: true,
food_id: food.id,
name: food.name,
};
}
else {
return { success: false };
}
}
catch (err) {
console.error(err);
return { success: false };
}
}
async addWater(req, res, body) {
try {
const amountMl = parseInt(body.amount_ml) || 250;
const date = body.date || new Date().toISOString().split('T')[0];
await this.waterLogModel.create({
UserId: req.user.id,
date: date,
amount_ml: amountMl,
time: new Date().toISOString(),
});
await this.utilsService.updateDailySummary(req.user.id, date);
req.flash('success_msg', `Added ${amountMl}ml of water!`);
res.redirect('/dashboard');
}
catch (err) {
console.error(err);
req.flash('error_msg', 'Error adding water');
res.redirect('/dashboard');
}
}
async addWeight(req, res, body) {
try {
const weightKg = parseFloat(body.weight_kg);
const date = body.date || new Date().toISOString().split('T')[0];
const weightLog = await this.weightLogModel.findOne({
where: { UserId: req.user.id, date: date },
});
if (weightLog) {
weightLog.weight_kg = weightKg;
weightLog.time = new Date().toISOString();
await weightLog.save();
}
else {
await this.weightLogModel.create({
UserId: req.user.id,
date: date,
weight_kg: weightKg,
time: new Date().toISOString(),
});
}
await this.utilsService.updateDailySummary(req.user.id, date);
res.redirect('/dashboard');
}
catch (err) {
console.error(err);
req.flash('error_msg', 'Error adding weight');
res.redirect('/dashboard');
}
}
};
exports.MealsController = MealsController;
__decorate([
(0, common_1.Get)('add-meal'),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Res)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", void 0)
], MealsController.prototype, "addMealPage", null);
__decorate([
(0, common_1.Post)('add-meal'),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Res)()),
__param(2, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Object]),
__metadata("design:returntype", Promise)
], MealsController.prototype, "addMeal", null);
__decorate([
(0, common_1.Get)('api/search-food'),
__param(0, (0, common_1.Query)('q')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", Promise)
], MealsController.prototype, "searchFood", null);
__decorate([
(0, common_1.Post)('api/add-food'),
__param(0, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], MealsController.prototype, "addFood", null);
__decorate([
(0, common_1.Post)('add-water'),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Res)()),
__param(2, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Object]),
__metadata("design:returntype", Promise)
], MealsController.prototype, "addWater", null);
__decorate([
(0, common_1.Post)('add-weight'),
__param(0, (0, common_1.Req)()),
__param(1, (0, common_1.Res)()),
__param(2, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object, Object]),
__metadata("design:returntype", Promise)
], MealsController.prototype, "addWeight", null);
exports.MealsController = MealsController = __decorate([
(0, common_1.Controller)(),
(0, common_1.UseGuards)(authenticated_guard_1.AuthenticatedGuard),
__param(2, (0, sequelize_1.InjectModel)(meal_model_1.Meal)),
__param(3, (0, sequelize_1.InjectModel)(meal_food_model_1.MealFood)),
__param(4, (0, sequelize_1.InjectModel)(food_item_model_1.FoodItem)),
__param(5, (0, sequelize_1.InjectModel)(water_log_model_1.WaterLog)),
__param(6, (0, sequelize_1.InjectModel)(weight_log_model_1.WeightLog)),
__metadata("design:paramtypes", [utils_service_1.UtilsService,
nutrition_service_1.NutritionService, Object, Object, Object, Object, Object])
], MealsController);
//# sourceMappingURL=meals.controller.js.map

1
dist/meals/meals.controller.js.map vendored Normal file

File diff suppressed because one or more lines are too long

2
dist/meals/meals.module.d.ts vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare class MealsModule {
}

39
dist/meals/meals.module.js vendored Normal file
View File

@@ -0,0 +1,39 @@
"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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MealsModule = void 0;
const common_1 = require("@nestjs/common");
const sequelize_1 = require("@nestjs/sequelize");
const meals_controller_1 = require("./meals.controller");
const nutrition_service_1 = require("./nutrition.service");
const meal_model_1 = require("../models/meal.model");
const meal_food_model_1 = require("../models/meal-food.model");
const food_item_model_1 = require("../models/food-item.model");
const water_log_model_1 = require("../models/water-log.model");
const weight_log_model_1 = require("../models/weight-log.model");
const api_cache_model_1 = require("../models/api-cache.model");
let MealsModule = class MealsModule {
};
exports.MealsModule = MealsModule;
exports.MealsModule = MealsModule = __decorate([
(0, common_1.Module)({
imports: [
sequelize_1.SequelizeModule.forFeature([
meal_model_1.Meal,
meal_food_model_1.MealFood,
food_item_model_1.FoodItem,
water_log_model_1.WaterLog,
weight_log_model_1.WeightLog,
api_cache_model_1.APICache,
]),
],
controllers: [meals_controller_1.MealsController],
providers: [nutrition_service_1.NutritionService],
})
], MealsModule);
//# sourceMappingURL=meals.module.js.map

1
dist/meals/meals.module.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"meals.module.js","sourceRoot":"","sources":["../../src/meals/meals.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,iDAAoD;AACpD,yDAAqD;AACrD,2DAAuD;AACvD,qDAA4C;AAC5C,+DAAqD;AACrD,+DAAqD;AACrD,+DAAqD;AACrD,iEAAuD;AACvD,+DAAqD;AAgB9C,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IAdvB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,2BAAe,CAAC,UAAU,CAAC;gBACzB,iBAAI;gBACJ,0BAAQ;gBACR,0BAAQ;gBACR,0BAAQ;gBACR,4BAAS;gBACT,0BAAQ;aACT,CAAC;SACH;QACD,WAAW,EAAE,CAAC,kCAAe,CAAC;QAC9B,SAAS,EAAE,CAAC,oCAAgB,CAAC;KAC9B,CAAC;GACW,WAAW,CAAG"}

52
dist/meals/nutrition.service.d.ts vendored Normal file
View File

@@ -0,0 +1,52 @@
import { ConfigService } from '@nestjs/config';
import { FoodItem } from '../models/food-item.model';
import { APICache } from '../models/api-cache.model';
export declare class NutritionService {
private configService;
private foodItemModel;
private apiCacheModel;
private apiKey;
private baseUrl;
private headers;
private cacheDurationDays;
constructor(configService: ConfigService, foodItemModel: typeof FoodItem, apiCacheModel: typeof APICache);
searchFood(query: string): Promise<{
name: any;
calories: any;
protein_g: any;
carbs_g: any;
fat_g: any;
fiber_g: any;
sugar_g: any;
sodium_mg: any;
serving_size_g: any;
source: string;
}[]>;
_getFromCache(query: string): Promise<{
name: any;
calories: any;
protein_g: any;
carbs_g: any;
fat_g: any;
fiber_g: any;
sugar_g: any;
sodium_mg: any;
serving_size_g: any;
source: string;
}[]>;
_saveToCache(query: string, source: string, data: any): Promise<void>;
_parseApiResponse(data: any[]): {
name: any;
calories: any;
protein_g: any;
carbs_g: any;
fat_g: any;
fiber_g: any;
sugar_g: any;
sodium_mg: any;
serving_size_g: any;
source: string;
}[];
saveFoodToDb(foodData: any): Promise<FoodItem>;
searchAllSources(query: string): Promise<any[]>;
}

215
dist/meals/nutrition.service.js vendored Normal file
View File

@@ -0,0 +1,215 @@
"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.NutritionService = void 0;
const common_1 = require("@nestjs/common");
const sequelize_1 = require("@nestjs/sequelize");
const config_1 = require("@nestjs/config");
const sequelize_2 = require("sequelize");
const axios_1 = require("axios");
const food_item_model_1 = require("../models/food-item.model");
const api_cache_model_1 = require("../models/api-cache.model");
let NutritionService = class NutritionService {
constructor(configService, foodItemModel, apiCacheModel) {
this.configService = configService;
this.foodItemModel = foodItemModel;
this.apiCacheModel = apiCacheModel;
this.apiKey = this.configService.get('API_NINJAS_KEY');
this.baseUrl = 'https://api.api-ninjas.com/v1/nutrition';
this.headers = { 'X-Api-Key': this.apiKey };
this.cacheDurationDays = 30;
}
async searchFood(query) {
const cached = await this._getFromCache(query);
if (cached) {
return cached;
}
try {
if (!this.apiKey) {
console.warn('API_NINJAS_KEY is not set');
return [];
}
const response = await axios_1.default.get(this.baseUrl, {
headers: this.headers,
params: { query: query },
timeout: 10000,
});
if (response.status === 200) {
const data = response.data;
await this._saveToCache(query, 'api_ninjas', data);
return this._parseApiResponse(data);
}
else {
console.error(`API Error: ${response.status}`);
return [];
}
}
catch (error) {
console.error(`API Request failed: ${error.message}`);
return [];
}
}
async _getFromCache(query) {
const cacheEntry = await this.apiCacheModel.findOne({
where: { query: query.toLowerCase() },
});
if (cacheEntry) {
const age = (new Date().getTime() - new Date(cacheEntry.cached_at).getTime()) / (1000 * 60 * 60 * 24);
if (age < this.cacheDurationDays) {
const data = JSON.parse(cacheEntry.response_json);
return this._parseApiResponse(data);
}
}
return null;
}
async _saveToCache(query, source, data) {
try {
let cacheEntry = await this.apiCacheModel.findOne({
where: { query: query.toLowerCase() },
});
if (cacheEntry) {
cacheEntry.response_json = JSON.stringify(data);
cacheEntry.cached_at = new Date();
await cacheEntry.save();
}
else {
await this.apiCacheModel.create({
query: query.toLowerCase(),
api_source: source,
response_json: JSON.stringify(data),
cached_at: new Date(),
});
}
}
catch (error) {
console.error(`Cache save failed: ${error.message}`);
}
}
_parseApiResponse(data) {
return data.map((item) => ({
name: (item.name || '').replace(/\b\w/g, (l) => l.toUpperCase()),
calories: item.calories || 0,
protein_g: item.protein_g || 0,
carbs_g: item.carbohydrates_total_g || 0,
fat_g: item.fat_total_g || 0,
fiber_g: item.fiber_g || 0,
sugar_g: item.sugar_g || 0,
sodium_mg: item.sodium_mg || 0,
serving_size_g: item.serving_size_g || 100,
source: 'api_ninjas',
}));
}
async saveFoodToDb(foodData) {
try {
const existing = await this.foodItemModel.findOne({
where: {
name: foodData.name,
source: foodData.source || 'api',
},
});
if (existing) {
return existing;
}
const food = await this.foodItemModel.create({
name: foodData.name,
calories: foodData.calories,
protein_g: foodData.protein_g || 0,
carbs_g: foodData.carbs_g || 0,
fat_g: foodData.fat_g || 0,
fiber_g: foodData.fiber_g || 0,
sugar_g: foodData.sugar_g || 0,
sodium_mg: foodData.sodium_mg || 0,
serving_size_g: foodData.serving_size_g || 100,
serving_description: foodData.serving_description || '1 serving',
source: foodData.source || 'api',
api_data: JSON.stringify(foodData),
});
return food;
}
catch (error) {
console.error(`Error saving food to DB: ${error.message}`);
return null;
}
}
async searchAllSources(query) {
const results = [];
const filipinoFoods = await this.foodItemModel.findAll({
where: {
is_filipino: true,
[sequelize_2.Op.or]: [
{ name: { [sequelize_2.Op.like]: `%${query}%` } },
{ name_tagalog: { [sequelize_2.Op.like]: `%${query}%` } },
],
},
limit: 5,
});
for (const food of filipinoFoods) {
results.push({
id: food.id,
name: food.name,
name_tagalog: food.name_tagalog,
calories: food.calories,
protein_g: food.protein_g,
carbs_g: food.carbs_g,
fat_g: food.fat_g,
serving_description: food.serving_description,
source: 'filipino',
category: food.category,
});
}
const otherFoods = await this.foodItemModel.findAll({
where: {
is_filipino: false,
name: { [sequelize_2.Op.like]: `%${query}%` },
},
limit: 5,
});
for (const food of otherFoods) {
results.push({
id: food.id,
name: food.name,
calories: food.calories,
protein_g: food.protein_g,
carbs_g: food.carbs_g,
fat_g: food.fat_g,
serving_description: food.serving_description,
source: food.source,
});
}
if (results.length < 3 && this.apiKey) {
const apiResults = await this.searchFood(query);
for (const foodData of apiResults.slice(0, 5)) {
results.push({
name: foodData.name,
calories: foodData.calories,
protein_g: foodData.protein_g,
carbs_g: foodData.carbs_g || 0,
fat_g: foodData.fat_g || 0,
serving_description: '100g',
source: 'api_ninjas',
raw_data: foodData,
});
}
}
return results;
}
};
exports.NutritionService = NutritionService;
exports.NutritionService = NutritionService = __decorate([
(0, common_1.Injectable)(),
__param(1, (0, sequelize_1.InjectModel)(food_item_model_1.FoodItem)),
__param(2, (0, sequelize_1.InjectModel)(api_cache_model_1.APICache)),
__metadata("design:paramtypes", [config_1.ConfigService, Object, Object])
], NutritionService);
//# sourceMappingURL=nutrition.service.js.map

1
dist/meals/nutrition.service.js.map vendored Normal file

File diff suppressed because one or more lines are too long

7
dist/models/api-cache.model.d.ts vendored Normal file
View File

@@ -0,0 +1,7 @@
import { Model } from 'sequelize-typescript';
export declare class APICache extends Model {
query: string;
api_source: string;
response_json: string;
cached_at: Date;
}

36
dist/models/api-cache.model.js vendored Normal file
View File

@@ -0,0 +1,36 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.APICache = void 0;
const sequelize_typescript_1 = require("sequelize-typescript");
let APICache = class APICache extends sequelize_typescript_1.Model {
};
exports.APICache = APICache;
__decorate([
(0, sequelize_typescript_1.Column)({ unique: true, allowNull: false }),
__metadata("design:type", String)
], APICache.prototype, "query", void 0);
__decorate([
sequelize_typescript_1.Column,
__metadata("design:type", String)
], APICache.prototype, "api_source", void 0);
__decorate([
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT),
__metadata("design:type", String)
], APICache.prototype, "response_json", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ defaultValue: sequelize_typescript_1.DataType.NOW }),
__metadata("design:type", Date)
], APICache.prototype, "cached_at", void 0);
exports.APICache = APICache = __decorate([
sequelize_typescript_1.Table
], APICache);
//# sourceMappingURL=api-cache.model.js.map

1
dist/models/api-cache.model.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"api-cache.model.js","sourceRoot":"","sources":["../../src/models/api-cache.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAAsE;AAG/D,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,4BAAK;CAYlC,CAAA;AAZY,4BAAQ;AAEnB;IADC,IAAA,6BAAM,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;uCAC7B;AAGd;IADC,6BAAM;;4CACY;AAGnB;IADC,IAAA,6BAAM,EAAC,+BAAQ,CAAC,IAAI,CAAC;;+CACA;AAGtB;IADC,IAAA,6BAAM,EAAC,EAAE,YAAY,EAAE,+BAAQ,CAAC,GAAG,EAAE,CAAC;8BAC5B,IAAI;2CAAC;mBAXL,QAAQ;IADpB,4BAAK;GACO,QAAQ,CAYpB"}

15
dist/models/daily-summary.model.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
import { Model } from 'sequelize-typescript';
import { User } from './user.model';
export declare class DailySummary extends Model {
UserId: number;
user: User;
date: Date;
total_calories: number;
total_protein_g: number;
total_carbs_g: number;
total_fat_g: number;
total_water_ml: number;
calories_remaining: number;
weight_kg: number;
notes: string;
}

66
dist/models/daily-summary.model.js vendored Normal file
View File

@@ -0,0 +1,66 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DailySummary = void 0;
const sequelize_typescript_1 = require("sequelize-typescript");
const user_model_1 = require("./user.model");
let DailySummary = class DailySummary extends sequelize_typescript_1.Model {
};
exports.DailySummary = DailySummary;
__decorate([
(0, sequelize_typescript_1.ForeignKey)(() => user_model_1.User),
sequelize_typescript_1.Column,
__metadata("design:type", Number)
], DailySummary.prototype, "UserId", void 0);
__decorate([
(0, sequelize_typescript_1.BelongsTo)(() => user_model_1.User),
__metadata("design:type", user_model_1.User)
], DailySummary.prototype, "user", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.DATEONLY, allowNull: false }),
__metadata("design:type", Date)
], DailySummary.prototype, "date", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, defaultValue: 0 }),
__metadata("design:type", Number)
], DailySummary.prototype, "total_calories", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, defaultValue: 0 }),
__metadata("design:type", Number)
], DailySummary.prototype, "total_protein_g", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, defaultValue: 0 }),
__metadata("design:type", Number)
], DailySummary.prototype, "total_carbs_g", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, defaultValue: 0 }),
__metadata("design:type", Number)
], DailySummary.prototype, "total_fat_g", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ defaultValue: 0 }),
__metadata("design:type", Number)
], DailySummary.prototype, "total_water_ml", void 0);
__decorate([
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.FLOAT),
__metadata("design:type", Number)
], DailySummary.prototype, "calories_remaining", void 0);
__decorate([
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.FLOAT),
__metadata("design:type", Number)
], DailySummary.prototype, "weight_kg", void 0);
__decorate([
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT),
__metadata("design:type", String)
], DailySummary.prototype, "notes", void 0);
exports.DailySummary = DailySummary = __decorate([
sequelize_typescript_1.Table
], DailySummary);
//# sourceMappingURL=daily-summary.model.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"daily-summary.model.js","sourceRoot":"","sources":["../../src/models/daily-summary.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAA6F;AAC7F,6CAAoC;AAG7B,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,4BAAK;CAkCtC,CAAA;AAlCY,oCAAY;AAGvB;IAFC,IAAA,iCAAU,EAAC,GAAG,EAAE,CAAC,iBAAI,CAAC;IACtB,6BAAM;;4CACQ;AAGf;IADC,IAAA,gCAAS,EAAC,GAAG,EAAE,CAAC,iBAAI,CAAC;8BAChB,iBAAI;0CAAC;AAGX;IADC,IAAA,6BAAM,EAAC,EAAE,IAAI,EAAE,+BAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;8BAChD,IAAI;0CAAC;AAGX;IADC,IAAA,6BAAM,EAAC,EAAE,IAAI,EAAE,+BAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;;oDAC3B;AAGvB;IADC,IAAA,6BAAM,EAAC,EAAE,IAAI,EAAE,+BAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;;qDAC1B;AAGxB;IADC,IAAA,6BAAM,EAAC,EAAE,IAAI,EAAE,+BAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;;mDAC5B;AAGtB;IADC,IAAA,6BAAM,EAAC,EAAE,IAAI,EAAE,+BAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;;iDAC9B;AAGpB;IADC,IAAA,6BAAM,EAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;;oDACL;AAGvB;IADC,IAAA,6BAAM,EAAC,+BAAQ,CAAC,KAAK,CAAC;;wDACI;AAG3B;IADC,IAAA,6BAAM,EAAC,+BAAQ,CAAC,KAAK,CAAC;;+CACL;AAGlB;IADC,IAAA,6BAAM,EAAC,+BAAQ,CAAC,IAAI,CAAC;;2CACR;uBAjCH,YAAY;IADxB,4BAAK;GACO,YAAY,CAkCxB"}

24
dist/models/food-item.model.d.ts vendored Normal file
View File

@@ -0,0 +1,24 @@
import { Model } from 'sequelize-typescript';
import { MealFood } from './meal-food.model';
import { PlannedFood } from './planned-food.model';
export declare class FoodItem extends Model {
name: string;
name_tagalog: string;
category: string;
calories: number;
protein_g: number;
carbs_g: number;
fat_g: number;
fiber_g: number;
sugar_g: number;
sodium_mg: number;
serving_size_g: number;
serving_description: string;
source: string;
is_filipino: boolean;
is_favorite: boolean;
api_data: string;
last_updated: Date;
mealFoods: MealFood[];
plannedFoods: PlannedFood[];
}

98
dist/models/food-item.model.js vendored Normal file
View File

@@ -0,0 +1,98 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FoodItem = void 0;
const sequelize_typescript_1 = require("sequelize-typescript");
const meal_food_model_1 = require("./meal-food.model");
const planned_food_model_1 = require("./planned-food.model");
let FoodItem = class FoodItem extends sequelize_typescript_1.Model {
};
exports.FoodItem = FoodItem;
__decorate([
(0, sequelize_typescript_1.Column)({ allowNull: false }),
__metadata("design:type", String)
], FoodItem.prototype, "name", void 0);
__decorate([
sequelize_typescript_1.Column,
__metadata("design:type", String)
], FoodItem.prototype, "name_tagalog", void 0);
__decorate([
sequelize_typescript_1.Column,
__metadata("design:type", String)
], FoodItem.prototype, "category", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, allowNull: false }),
__metadata("design:type", Number)
], FoodItem.prototype, "calories", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, defaultValue: 0 }),
__metadata("design:type", Number)
], FoodItem.prototype, "protein_g", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, defaultValue: 0 }),
__metadata("design:type", Number)
], FoodItem.prototype, "carbs_g", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, defaultValue: 0 }),
__metadata("design:type", Number)
], FoodItem.prototype, "fat_g", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, defaultValue: 0 }),
__metadata("design:type", Number)
], FoodItem.prototype, "fiber_g", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, defaultValue: 0 }),
__metadata("design:type", Number)
], FoodItem.prototype, "sugar_g", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, defaultValue: 0 }),
__metadata("design:type", Number)
], FoodItem.prototype, "sodium_mg", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, defaultValue: 100 }),
__metadata("design:type", Number)
], FoodItem.prototype, "serving_size_g", void 0);
__decorate([
sequelize_typescript_1.Column,
__metadata("design:type", String)
], FoodItem.prototype, "serving_description", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ defaultValue: 'manual' }),
__metadata("design:type", String)
], FoodItem.prototype, "source", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ defaultValue: false }),
__metadata("design:type", Boolean)
], FoodItem.prototype, "is_filipino", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ defaultValue: false }),
__metadata("design:type", Boolean)
], FoodItem.prototype, "is_favorite", void 0);
__decorate([
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT),
__metadata("design:type", String)
], FoodItem.prototype, "api_data", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ defaultValue: sequelize_typescript_1.DataType.NOW }),
__metadata("design:type", Date)
], FoodItem.prototype, "last_updated", void 0);
__decorate([
(0, sequelize_typescript_1.HasMany)(() => meal_food_model_1.MealFood),
__metadata("design:type", Array)
], FoodItem.prototype, "mealFoods", void 0);
__decorate([
(0, sequelize_typescript_1.HasMany)(() => planned_food_model_1.PlannedFood),
__metadata("design:type", Array)
], FoodItem.prototype, "plannedFoods", void 0);
exports.FoodItem = FoodItem = __decorate([
sequelize_typescript_1.Table
], FoodItem);
//# sourceMappingURL=food-item.model.js.map

1
dist/models/food-item.model.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"food-item.model.js","s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AGvB;IADC,6BAAM;;qDACqB;AAG5B;IADC,IAAA,6BAAM,EAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;;wCACpB;AAGf;IADC,IAAA,6BAAM,EAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;;6CACX;AAGrB;IADC,IAAA,6BAAM,EAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;;6CACX;AAGrB;IADC,IAAA,6BAAM,EAAC,+BAAQ,CAAC,IAAI,CAAC;;0CACL;AAGjB;IADC,IAAA,6BAAM,EAAC,EAAE,YAAY,EAAE,+BAAQ,CAAC,GAAG,EAAE,CAAC;8BACzB,IAAI;8CAAC;AAGnB;IADC,IAAA,8BAAO,EAAC,GAAG,EAAE,CAAC,0BAAQ,CAAC;;2CACF;AAGtB;IADC,IAAA,8BAAO,EAAC,GAAG,EAAE,CAAC,gCAAW,CAAC;;8CACC;mBAxDjB,QAAQ;IADpB,4BAAK;GACO,QAAQ,CAyDpB"}

15
dist/models/meal-food.model.d.ts vendored Normal file
View File

@@ -0,0 +1,15 @@
import { Model } from 'sequelize-typescript';
import { Meal } from './meal.model';
import { FoodItem } from './food-item.model';
export declare class MealFood extends Model {
MealId: number;
meal: Meal;
FoodItemId: number;
foodItem: FoodItem;
quantity: number;
quantity_grams: number;
calories_consumed: number;
protein_consumed: number;
carbs_consumed: number;
fat_consumed: number;
}

64
dist/models/meal-food.model.js vendored Normal file
View File

@@ -0,0 +1,64 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MealFood = void 0;
const sequelize_typescript_1 = require("sequelize-typescript");
const meal_model_1 = require("./meal.model");
const food_item_model_1 = require("./food-item.model");
let MealFood = class MealFood extends sequelize_typescript_1.Model {
};
exports.MealFood = MealFood;
__decorate([
(0, sequelize_typescript_1.ForeignKey)(() => meal_model_1.Meal),
sequelize_typescript_1.Column,
__metadata("design:type", Number)
], MealFood.prototype, "MealId", void 0);
__decorate([
(0, sequelize_typescript_1.BelongsTo)(() => meal_model_1.Meal),
__metadata("design:type", meal_model_1.Meal)
], MealFood.prototype, "meal", void 0);
__decorate([
(0, sequelize_typescript_1.ForeignKey)(() => food_item_model_1.FoodItem),
sequelize_typescript_1.Column,
__metadata("design:type", Number)
], MealFood.prototype, "FoodItemId", void 0);
__decorate([
(0, sequelize_typescript_1.BelongsTo)(() => food_item_model_1.FoodItem),
__metadata("design:type", food_item_model_1.FoodItem)
], MealFood.prototype, "foodItem", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, allowNull: false, defaultValue: 1.0 }),
__metadata("design:type", Number)
], MealFood.prototype, "quantity", void 0);
__decorate([
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.FLOAT),
__metadata("design:type", Number)
], MealFood.prototype, "quantity_grams", void 0);
__decorate([
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.FLOAT),
__metadata("design:type", Number)
], MealFood.prototype, "calories_consumed", void 0);
__decorate([
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.FLOAT),
__metadata("design:type", Number)
], MealFood.prototype, "protein_consumed", void 0);
__decorate([
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.FLOAT),
__metadata("design:type", Number)
], MealFood.prototype, "carbs_consumed", void 0);
__decorate([
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.FLOAT),
__metadata("design:type", Number)
], MealFood.prototype, "fat_consumed", void 0);
exports.MealFood = MealFood = __decorate([
sequelize_typescript_1.Table
], MealFood);
//# sourceMappingURL=meal-food.model.js.map

1
dist/models/meal-food.model.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"meal-food.model.js","sourceRoot":"","sources":["../../src/models/meal-food.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAA6F;AAC7F,6CAAoC;AACpC,uDAA6C;AAGtC,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,4BAAK;CAgClC,CAAA;AAhCY,4BAAQ;AAGnB;IAFC,IAAA,iCAAU,EAAC,GAAG,EAAE,CAAC,iBAAI,CAAC;IACtB,6BAAM;;wCACQ;AAGf;IADC,IAAA,gCAAS,EAAC,GAAG,EAAE,CAAC,iBAAI,CAAC;8BAChB,iBAAI;sCAAC;AAIX;IAFC,IAAA,iCAAU,EAAC,GAAG,EAAE,CAAC,0BAAQ,CAAC;IAC1B,6BAAM;;4CACY;AAGnB;IADC,IAAA,gCAAS,EAAC,GAAG,EAAE,CAAC,0BAAQ,CAAC;8BAChB,0BAAQ;0CAAC;AAGnB;IADC,IAAA,6BAAM,EAAC,EAAE,IAAI,EAAE,+BAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC;;0CACrD;AAGjB;IADC,IAAA,6BAAM,EAAC,+BAAQ,CAAC,KAAK,CAAC;;gDACA;AAGvB;IADC,IAAA,6BAAM,EAAC,+BAAQ,CAAC,KAAK,CAAC;;mDACG;AAG1B;IADC,IAAA,6BAAM,EAAC,+BAAQ,CAAC,KAAK,CAAC;;kDACE;AAGzB;IADC,IAAA,6BAAM,EAAC,+BAAQ,CAAC,KAAK,CAAC;;gDACA;AAGvB;IADC,IAAA,6BAAM,EAAC,+BAAQ,CAAC,KAAK,CAAC;;8CACF;mBA/BV,QAAQ;IADpB,4BAAK;GACO,QAAQ,CAgCpB"}

12
dist/models/meal-plan.model.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
import { Model } from 'sequelize-typescript';
import { User } from './user.model';
import { PlannedFood } from './planned-food.model';
export declare class MealPlan extends Model {
UserId: number;
user: User;
date: Date;
meal_type: string;
is_completed: boolean;
notes: string;
plannedFoods: PlannedFood[];
}

51
dist/models/meal-plan.model.js vendored Normal file
View File

@@ -0,0 +1,51 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MealPlan = void 0;
const sequelize_typescript_1 = require("sequelize-typescript");
const user_model_1 = require("./user.model");
const planned_food_model_1 = require("./planned-food.model");
let MealPlan = class MealPlan extends sequelize_typescript_1.Model {
};
exports.MealPlan = MealPlan;
__decorate([
(0, sequelize_typescript_1.ForeignKey)(() => user_model_1.User),
sequelize_typescript_1.Column,
__metadata("design:type", Number)
], MealPlan.prototype, "UserId", void 0);
__decorate([
(0, sequelize_typescript_1.BelongsTo)(() => user_model_1.User),
__metadata("design:type", user_model_1.User)
], MealPlan.prototype, "user", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.DATEONLY, allowNull: false }),
__metadata("design:type", Date)
], MealPlan.prototype, "date", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ allowNull: false }),
__metadata("design:type", String)
], MealPlan.prototype, "meal_type", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ defaultValue: false }),
__metadata("design:type", Boolean)
], MealPlan.prototype, "is_completed", void 0);
__decorate([
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT),
__metadata("design:type", String)
], MealPlan.prototype, "notes", void 0);
__decorate([
(0, sequelize_typescript_1.HasMany)(() => planned_food_model_1.PlannedFood),
__metadata("design:type", Array)
], MealPlan.prototype, "plannedFoods", void 0);
exports.MealPlan = MealPlan = __decorate([
sequelize_typescript_1.Table
], MealPlan);
//# sourceMappingURL=meal-plan.model.js.map

1
dist/models/meal-plan.model.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"meal-plan.model.js","sourceRoot":"","sources":["../../src/models/meal-plan.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAAsG;AACtG,6CAAoC;AACpC,6DAAmD;AAG5C,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,4BAAK;CAsBlC,CAAA;AAtBY,4BAAQ;AAGnB;IAFC,IAAA,iCAAU,EAAC,GAAG,EAAE,CAAC,iBAAI,CAAC;IACtB,6BAAM;;wCACQ;AAGf;IADC,IAAA,gCAAS,EAAC,GAAG,EAAE,CAAC,iBAAI,CAAC;8BAChB,iBAAI;sCAAC;AAGX;IADC,IAAA,6BAAM,EAAC,EAAE,IAAI,EAAE,+BAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;8BAChD,IAAI;sCAAC;AAGX;IADC,IAAA,6BAAM,EAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;2CACX;AAGlB;IADC,IAAA,6BAAM,EAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;;8CACV;AAGtB;IADC,IAAA,6BAAM,EAAC,+BAAQ,CAAC,IAAI,CAAC;;uCACR;AAGd;IADC,IAAA,8BAAO,EAAC,GAAG,EAAE,CAAC,gCAAW,CAAC;;8CACC;mBArBjB,QAAQ;IADpB,4BAAK;GACO,QAAQ,CAsBpB"}

12
dist/models/meal.model.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
import { Model } from 'sequelize-typescript';
import { User } from './user.model';
import { MealFood } from './meal-food.model';
export declare class Meal extends Model {
UserId: number;
user: User;
date: Date;
meal_type: string;
time: string;
notes: string;
mealFoods: MealFood[];
}

51
dist/models/meal.model.js vendored Normal file
View File

@@ -0,0 +1,51 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Meal = void 0;
const sequelize_typescript_1 = require("sequelize-typescript");
const user_model_1 = require("./user.model");
const meal_food_model_1 = require("./meal-food.model");
let Meal = class Meal extends sequelize_typescript_1.Model {
};
exports.Meal = Meal;
__decorate([
(0, sequelize_typescript_1.ForeignKey)(() => user_model_1.User),
sequelize_typescript_1.Column,
__metadata("design:type", Number)
], Meal.prototype, "UserId", void 0);
__decorate([
(0, sequelize_typescript_1.BelongsTo)(() => user_model_1.User),
__metadata("design:type", user_model_1.User)
], Meal.prototype, "user", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.DATEONLY, allowNull: false, defaultValue: sequelize_typescript_1.DataType.NOW }),
__metadata("design:type", Date)
], Meal.prototype, "date", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ allowNull: false }),
__metadata("design:type", String)
], Meal.prototype, "meal_type", void 0);
__decorate([
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TIME),
__metadata("design:type", String)
], Meal.prototype, "time", void 0);
__decorate([
(0, sequelize_typescript_1.Column)(sequelize_typescript_1.DataType.TEXT),
__metadata("design:type", String)
], Meal.prototype, "notes", void 0);
__decorate([
(0, sequelize_typescript_1.HasMany)(() => meal_food_model_1.MealFood),
__metadata("design:type", Array)
], Meal.prototype, "mealFoods", void 0);
exports.Meal = Meal = __decorate([
sequelize_typescript_1.Table
], Meal);
//# sourceMappingURL=meal.model.js.map

1
dist/models/meal.model.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"meal.model.js","sourceRoot":"","sources":["../../src/models/meal.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAAsG;AACtG,6CAAoC;AACpC,uDAA6C;AAGtC,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,4BAAK;CAsB9B,CAAA;AAtBY,oBAAI;AAGf;IAFC,IAAA,iCAAU,EAAC,GAAG,EAAE,CAAC,iBAAI,CAAC;IACtB,6BAAM;;oCACQ;AAGf;IADC,IAAA,gCAAS,EAAC,GAAG,EAAE,CAAC,iBAAI,CAAC;8BAChB,iBAAI;kCAAC;AAGX;IADC,IAAA,6BAAM,EAAC,EAAE,IAAI,EAAE,+BAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,+BAAQ,CAAC,GAAG,EAAE,CAAC;8BAC5E,IAAI;kCAAC;AAGX;IADC,IAAA,6BAAM,EAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;;uCACX;AAGlB;IADC,IAAA,6BAAM,EAAC,+BAAQ,CAAC,IAAI,CAAC;;kCACT;AAGb;IADC,IAAA,6BAAM,EAAC,+BAAQ,CAAC,IAAI,CAAC;;mCACR;AAGd;IADC,IAAA,8BAAO,EAAC,GAAG,EAAE,CAAC,0BAAQ,CAAC;;uCACF;eArBX,IAAI;IADhB,4BAAK;GACO,IAAI,CAsBhB"}

10
dist/models/planned-food.model.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
import { Model } from 'sequelize-typescript';
import { MealPlan } from './meal-plan.model';
import { FoodItem } from './food-item.model';
export declare class PlannedFood extends Model {
MealPlanId: number;
mealPlan: MealPlan;
FoodItemId: number;
foodItem: FoodItem;
quantity: number;
}

44
dist/models/planned-food.model.js vendored Normal file
View File

@@ -0,0 +1,44 @@
"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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlannedFood = void 0;
const sequelize_typescript_1 = require("sequelize-typescript");
const meal_plan_model_1 = require("./meal-plan.model");
const food_item_model_1 = require("./food-item.model");
let PlannedFood = class PlannedFood extends sequelize_typescript_1.Model {
};
exports.PlannedFood = PlannedFood;
__decorate([
(0, sequelize_typescript_1.ForeignKey)(() => meal_plan_model_1.MealPlan),
sequelize_typescript_1.Column,
__metadata("design:type", Number)
], PlannedFood.prototype, "MealPlanId", void 0);
__decorate([
(0, sequelize_typescript_1.BelongsTo)(() => meal_plan_model_1.MealPlan),
__metadata("design:type", meal_plan_model_1.MealPlan)
], PlannedFood.prototype, "mealPlan", void 0);
__decorate([
(0, sequelize_typescript_1.ForeignKey)(() => food_item_model_1.FoodItem),
sequelize_typescript_1.Column,
__metadata("design:type", Number)
], PlannedFood.prototype, "FoodItemId", void 0);
__decorate([
(0, sequelize_typescript_1.BelongsTo)(() => food_item_model_1.FoodItem),
__metadata("design:type", food_item_model_1.FoodItem)
], PlannedFood.prototype, "foodItem", void 0);
__decorate([
(0, sequelize_typescript_1.Column)({ type: sequelize_typescript_1.DataType.FLOAT, allowNull: false, defaultValue: 1.0 }),
__metadata("design:type", Number)
], PlannedFood.prototype, "quantity", void 0);
exports.PlannedFood = PlannedFood = __decorate([
sequelize_typescript_1.Table
], PlannedFood);
//# sourceMappingURL=planned-food.model.js.map

1
dist/models/planned-food.model.js.map vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"planned-food.model.js","sourceRoot":"","sources":["../../src/models/planned-food.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+DAA6F;AAC7F,uDAA6C;AAC7C,uDAA6C;AAGtC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,4BAAK;CAiBrC,CAAA;AAjBY,kCAAW;AAGtB;IAFC,IAAA,iCAAU,EAAC,GAAG,EAAE,CAAC,0BAAQ,CAAC;IAC1B,6BAAM;;+CACY;AAGnB;IADC,IAAA,gCAAS,EAAC,GAAG,EAAE,CAAC,0BAAQ,CAAC;8BAChB,0BAAQ;6CAAC;AAInB;IAFC,IAAA,iCAAU,EAAC,GAAG,EAAE,CAAC,0BAAQ,CAAC;IAC1B,6BAAM;;+CACY;AAGnB;IADC,IAAA,gCAAS,EAAC,GAAG,EAAE,CAAC,0BAAQ,CAAC;8BAChB,0BAAQ;6CAAC;AAGnB;IADC,IAAA,6BAAM,EAAC,EAAE,IAAI,EAAE,+BAAQ,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC;;6CACrD;sBAhBN,WAAW;IADvB,4BAAK;GACO,WAAW,CAiBvB"}

13
dist/models/user-goal.model.d.ts vendored Normal file
View File

@@ -0,0 +1,13 @@
import { Model } from 'sequelize-typescript';
import { User } from './user.model';
export declare class UserGoal extends Model {
UserId: number;
user: User;
goal_type: string;
target_weight_kg: number;
weekly_goal_kg: number;
target_protein_g: number;
target_carbs_g: number;
target_fat_g: number;
target_water_ml: number;
}

Some files were not shown because too many files have changed in this diff Show More