Spaces:
Sleeping
Sleeping
Merge pull request #59 from Modarb-Ai-Trainer:mealPlan
Browse files- src/common/enums/meal-type.enum.ts +6 -0
- src/common/models/ingredient.model.ts +34 -0
- src/common/models/meal-plan.model.ts +47 -0
- src/common/models/meal.model.ts +36 -0
- src/common/models/template.model.ts +0 -1
- src/common/models/user-registered-meal-plan.model.ts +37 -0
- src/common/serializers/ingredient.serialization.ts +41 -0
- src/common/serializers/meal-plan.serialization.ts +65 -0
- src/common/serializers/meal.serialization.ts +37 -0
- src/common/serializers/user-registered-meal-plan.serialization.ts +46 -0
- src/modules/console/modules/exercises/validations/create-excercise.validation.ts +1 -1
- src/modules/console/modules/ingredients/validations/create-ingredient.validation.ts +64 -0
- src/modules/console/modules/ingredients/validations/update-ingredient.validation.ts +55 -0
- src/modules/console/modules/meal-plans/validations/create-meal-plan.validation.ts +96 -0
- src/modules/console/modules/meal-plans/validations/update-meal-plan.validation.ts +89 -0
- src/modules/console/modules/meals/validations/create-meals.validation.ts +56 -0
- src/modules/console/modules/meals/validations/update-meals.validation.ts +49 -0
- src/modules/users/modules/user-registered-meal-plans/validations/create-user-registered-meal-plan.validation.ts +63 -0
- src/modules/users/modules/user-registered-meal-plans/validations/update-user-registered-meal-plan.validation.ts +54 -0
- src/modules/users/modules/workouts/controllers/workouts.controller.ts +8 -4
src/common/enums/meal-type.enum.ts
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export enum MealType {
|
2 |
+
BREAKFAST = "breakfast",
|
3 |
+
LUNCH = "lunch",
|
4 |
+
SNACKS = "snacks",
|
5 |
+
DINNER = "dinner",
|
6 |
+
}
|
src/common/models/ingredient.model.ts
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import mongoose from "mongoose";
|
2 |
+
const { Schema } = mongoose;
|
3 |
+
|
4 |
+
export interface IIngredient {
|
5 |
+
name: string;
|
6 |
+
serving_size: number;
|
7 |
+
servings_count: number;
|
8 |
+
serving_size_unit: string;
|
9 |
+
servings_count_unit: string;
|
10 |
+
calories: number;
|
11 |
+
carbs: number;
|
12 |
+
proteins: number;
|
13 |
+
fats: number;
|
14 |
+
}
|
15 |
+
|
16 |
+
const ingredientSchema = new Schema({
|
17 |
+
name: { type: String, required: true, unique: true, dropDups: true },
|
18 |
+
serving_size: { type: Number, required: true },
|
19 |
+
servings_count: { type: Number, required: true },
|
20 |
+
serving_size_unit: { type: String, required: true },
|
21 |
+
servings_count_unit: { type: String, required: true },
|
22 |
+
calories: { type: Number, required: true },
|
23 |
+
carbs: { type: Number, required: true },
|
24 |
+
proteins: { type: Number, required: true },
|
25 |
+
fats: { type: Number, required: true },
|
26 |
+
});
|
27 |
+
|
28 |
+
|
29 |
+
export type IngredientDocument = IIngredient & mongoose.Document;
|
30 |
+
|
31 |
+
export const Ingredient = mongoose.model<IngredientDocument>(
|
32 |
+
"ingredients",
|
33 |
+
ingredientSchema
|
34 |
+
);
|
src/common/models/meal-plan.model.ts
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import mongoose from "mongoose";
|
2 |
+
const { Schema } = mongoose;
|
3 |
+
import { FitnessLevel } from "@common/enums/fitness-level.enum";
|
4 |
+
|
5 |
+
export interface IMealPlan {
|
6 |
+
image: string;
|
7 |
+
description: string;
|
8 |
+
Duration: number;
|
9 |
+
Level: FitnessLevel;
|
10 |
+
your_Journey: string;
|
11 |
+
key_Features: {
|
12 |
+
title: string;
|
13 |
+
description: string;
|
14 |
+
}[];
|
15 |
+
days: {
|
16 |
+
day_number: number;
|
17 |
+
meals: mongoose.Types.ObjectId[];
|
18 |
+
}[];
|
19 |
+
}
|
20 |
+
|
21 |
+
const mealPlanSchema = new Schema({
|
22 |
+
Image: { type: String, required: true },
|
23 |
+
description: { type: String, required: true },
|
24 |
+
Duration: { type: Number, required: true },
|
25 |
+
Level: { type: String, enum: FitnessLevel, required: true },
|
26 |
+
your_Journey: { type: String, required: true },
|
27 |
+
key_Features: [{
|
28 |
+
title: { type: String, required: true },
|
29 |
+
description: { type: String, required: true },
|
30 |
+
}],
|
31 |
+
days: [
|
32 |
+
{
|
33 |
+
day_number: { type: Number, required: true, },
|
34 |
+
meals: [
|
35 |
+
{ type: mongoose.Types.ObjectId, ref: "meals" },
|
36 |
+
],
|
37 |
+
},
|
38 |
+
],
|
39 |
+
});
|
40 |
+
|
41 |
+
|
42 |
+
export type MealPlanDocument = IMealPlan & mongoose.Document;
|
43 |
+
|
44 |
+
export const MealPlan = mongoose.model<MealPlanDocument>(
|
45 |
+
"mealPlans",
|
46 |
+
mealPlanSchema
|
47 |
+
);
|
src/common/models/meal.model.ts
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import mongoose from "mongoose";
|
2 |
+
const { Schema } = mongoose;
|
3 |
+
import { MealType } from "@common/enums/meal-type.enum";
|
4 |
+
export interface IMeal {
|
5 |
+
name: string;
|
6 |
+
created_at: Date;
|
7 |
+
ingredients: [string];
|
8 |
+
calories: number;
|
9 |
+
carbs: number;
|
10 |
+
proteins: number;
|
11 |
+
fats: number;
|
12 |
+
type: MealType;
|
13 |
+
}
|
14 |
+
|
15 |
+
const mealSchema = new Schema({
|
16 |
+
name: { type: String, required: true, unique: true, dropDups: true },
|
17 |
+
created_at: { type: Date, default: Date.now() },
|
18 |
+
type: {
|
19 |
+
type: String,
|
20 |
+
enum: MealType,
|
21 |
+
required: true,
|
22 |
+
},
|
23 |
+
ingredients: [{ type: mongoose.Types.ObjectId, ref: "ingredients" }],
|
24 |
+
calories: { type: Number, required: true },
|
25 |
+
carbs: { type: Number, required: true },
|
26 |
+
proteins: { type: Number, required: true },
|
27 |
+
fats: { type: Number, required: true },
|
28 |
+
});
|
29 |
+
|
30 |
+
|
31 |
+
export type MealDocument = IMeal & mongoose.Document;
|
32 |
+
|
33 |
+
export const Meal = mongoose.model<MealDocument>(
|
34 |
+
"meals",
|
35 |
+
mealSchema
|
36 |
+
);
|
src/common/models/template.model.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import { date } from "joi";
|
2 |
import mongoose from "mongoose";
|
3 |
const { Schema } = mongoose;
|
4 |
|
|
|
|
|
1 |
import mongoose from "mongoose";
|
2 |
const { Schema } = mongoose;
|
3 |
|
src/common/models/user-registered-meal-plan.model.ts
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import mongoose from "mongoose";
|
2 |
+
const { Schema } = mongoose;
|
3 |
+
import { FitnessLevel } from "@common/enums/fitness-level.enum";
|
4 |
+
|
5 |
+
export interface IUserRegisteredMealPlan {
|
6 |
+
user: string;
|
7 |
+
isActive: boolean;
|
8 |
+
meal_plan: string;
|
9 |
+
days: {
|
10 |
+
day_number: number;
|
11 |
+
meals: string[];
|
12 |
+
is_eaten: boolean;
|
13 |
+
}[];
|
14 |
+
}
|
15 |
+
|
16 |
+
const userRegisteredMealPlanSchema = new Schema({
|
17 |
+
user: { type: mongoose.Types.ObjectId, ref: "users" },
|
18 |
+
isActive: { type: Boolean, default: true },
|
19 |
+
meal_plan: { type: mongoose.Types.ObjectId, ref: "mealPlans" },
|
20 |
+
days: [
|
21 |
+
{
|
22 |
+
day_number: { type: Number, required: true, },
|
23 |
+
meals: [
|
24 |
+
{ type: mongoose.Types.ObjectId, ref: "meals" },
|
25 |
+
],
|
26 |
+
is_eaten: { type: Boolean, default: false }
|
27 |
+
},
|
28 |
+
],
|
29 |
+
});
|
30 |
+
|
31 |
+
|
32 |
+
export type UserRegisteredMealPlanDocument = IUserRegisteredMealPlan & mongoose.Document;
|
33 |
+
|
34 |
+
export const UserRegisteredMealPlan = mongoose.model<UserRegisteredMealPlanDocument>(
|
35 |
+
"userRegisteredMealPlans",
|
36 |
+
userRegisteredMealPlanSchema
|
37 |
+
);
|
src/common/serializers/ingredient.serialization.ts
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Expose } from "class-transformer";
|
2 |
+
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
3 |
+
|
4 |
+
|
5 |
+
export class IngredientSerialization {
|
6 |
+
@Expose()
|
7 |
+
@SwaggerResponseProperty({ type: "string" })
|
8 |
+
name: string;
|
9 |
+
|
10 |
+
@Expose()
|
11 |
+
@SwaggerResponseProperty({ type: "number" })
|
12 |
+
serving_size: number;
|
13 |
+
|
14 |
+
@Expose()
|
15 |
+
@SwaggerResponseProperty({ type: "number" })
|
16 |
+
servings_count: number;
|
17 |
+
|
18 |
+
@Expose()
|
19 |
+
@SwaggerResponseProperty({ type: "string" })
|
20 |
+
serving_size_unit: string;
|
21 |
+
|
22 |
+
@Expose()
|
23 |
+
@SwaggerResponseProperty({ type: "string" })
|
24 |
+
servings_count_unit: string;
|
25 |
+
|
26 |
+
@Expose()
|
27 |
+
@SwaggerResponseProperty({ type: "number" })
|
28 |
+
calories: number;
|
29 |
+
|
30 |
+
@Expose()
|
31 |
+
@SwaggerResponseProperty({ type: "number" })
|
32 |
+
carbs: number;
|
33 |
+
|
34 |
+
@Expose()
|
35 |
+
@SwaggerResponseProperty({ type: "number" })
|
36 |
+
proteins: number;
|
37 |
+
|
38 |
+
@Expose()
|
39 |
+
@SwaggerResponseProperty({ type: "number" })
|
40 |
+
fats: number;
|
41 |
+
}
|
src/common/serializers/meal-plan.serialization.ts
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Expose, Transform } from "class-transformer";
|
2 |
+
import { serialize } from "@helpers/serialize";
|
3 |
+
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
4 |
+
|
5 |
+
|
6 |
+
class Days {
|
7 |
+
@Expose()
|
8 |
+
@SwaggerResponseProperty({ type: "string" })
|
9 |
+
title: string;
|
10 |
+
|
11 |
+
@Expose({ name: "meals" })
|
12 |
+
@SwaggerResponseProperty({ type: "string" })
|
13 |
+
meals: string;
|
14 |
+
}
|
15 |
+
|
16 |
+
class KeyFeatures {
|
17 |
+
@Expose()
|
18 |
+
@SwaggerResponseProperty({ type: "number" })
|
19 |
+
day_number: number;
|
20 |
+
|
21 |
+
@Expose({ name: "description" })
|
22 |
+
@SwaggerResponseProperty({ type: {} })
|
23 |
+
description: any;
|
24 |
+
}
|
25 |
+
|
26 |
+
export class WorkoutSerialization {
|
27 |
+
@Expose({ name: "_id" })
|
28 |
+
@SwaggerResponseProperty({ type: "string" })
|
29 |
+
id: string;
|
30 |
+
|
31 |
+
@Expose()
|
32 |
+
@SwaggerResponseProperty({ type: "string" })
|
33 |
+
image: string;
|
34 |
+
|
35 |
+
@Expose()
|
36 |
+
@SwaggerResponseProperty({ type: "string" })
|
37 |
+
description: string;
|
38 |
+
|
39 |
+
@Expose()
|
40 |
+
@SwaggerResponseProperty({ type: "string" })
|
41 |
+
Duration: string;
|
42 |
+
|
43 |
+
@Expose()
|
44 |
+
@SwaggerResponseProperty({ type: "string" })
|
45 |
+
Level: string;
|
46 |
+
|
47 |
+
@Expose()
|
48 |
+
@SwaggerResponseProperty({ type: "string" })
|
49 |
+
your_Journey: string;
|
50 |
+
|
51 |
+
@Expose({ name: "key_Features" })
|
52 |
+
@SwaggerResponseProperty({ type: [KeyFeatures] })
|
53 |
+
@Transform(
|
54 |
+
({ value }) => serialize(value, KeyFeatures)
|
55 |
+
)
|
56 |
+
key_Features: any;
|
57 |
+
|
58 |
+
@Expose({ name: "days" })
|
59 |
+
@SwaggerResponseProperty({ type: [Days] })
|
60 |
+
@Transform(
|
61 |
+
({ value }) => serialize(value, Days)
|
62 |
+
)
|
63 |
+
days: any;
|
64 |
+
|
65 |
+
}
|
src/common/serializers/meal.serialization.ts
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Expose } from "class-transformer";
|
2 |
+
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
3 |
+
|
4 |
+
|
5 |
+
export class MealSerialization {
|
6 |
+
@Expose()
|
7 |
+
@SwaggerResponseProperty({ type: "string" })
|
8 |
+
name: string;
|
9 |
+
|
10 |
+
@Expose()
|
11 |
+
@SwaggerResponseProperty({ type: "string" })
|
12 |
+
created_at: Date;
|
13 |
+
|
14 |
+
@Expose()
|
15 |
+
@SwaggerResponseProperty({ type: "string" })
|
16 |
+
ingredients: [string];
|
17 |
+
|
18 |
+
@Expose()
|
19 |
+
@SwaggerResponseProperty({ type: "number" })
|
20 |
+
calories: number;
|
21 |
+
|
22 |
+
@Expose()
|
23 |
+
@SwaggerResponseProperty({ type: "number" })
|
24 |
+
carbs: number;
|
25 |
+
|
26 |
+
@Expose()
|
27 |
+
@SwaggerResponseProperty({ type: "number" })
|
28 |
+
proteins: number;
|
29 |
+
|
30 |
+
@Expose()
|
31 |
+
@SwaggerResponseProperty({ type: "number" })
|
32 |
+
fats: number;
|
33 |
+
|
34 |
+
@Expose()
|
35 |
+
@SwaggerResponseProperty({ type: "string" })
|
36 |
+
type: string;
|
37 |
+
}
|
src/common/serializers/user-registered-meal-plan.serialization.ts
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Expose, Transform } from "class-transformer";
|
2 |
+
import { serialize } from "@helpers/serialize";
|
3 |
+
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
class Days {
|
8 |
+
@Expose()
|
9 |
+
@SwaggerResponseProperty({ type: "number" })
|
10 |
+
day_number: number;
|
11 |
+
|
12 |
+
@Expose({ name: "meals" })
|
13 |
+
@SwaggerResponseProperty({ type: {} })
|
14 |
+
meals: any;
|
15 |
+
|
16 |
+
@Expose()
|
17 |
+
@SwaggerResponseProperty({ type: "boolean" })
|
18 |
+
is_eaten: boolean;
|
19 |
+
|
20 |
+
}
|
21 |
+
|
22 |
+
export class WorkoutSerialization {
|
23 |
+
@Expose({ name: "_id" })
|
24 |
+
@SwaggerResponseProperty({ type: "string" })
|
25 |
+
id: string;
|
26 |
+
|
27 |
+
@Expose()
|
28 |
+
@SwaggerResponseProperty({ type: "string" })
|
29 |
+
user: string;
|
30 |
+
|
31 |
+
@Expose()
|
32 |
+
@SwaggerResponseProperty({ type: "string" })
|
33 |
+
meal_plan: string;
|
34 |
+
|
35 |
+
@Expose()
|
36 |
+
@SwaggerResponseProperty({ type: "boolean" })
|
37 |
+
isActive: boolean;
|
38 |
+
|
39 |
+
@Expose({ name: "days" })
|
40 |
+
@SwaggerResponseProperty({ type: [Days] })
|
41 |
+
@Transform(
|
42 |
+
({ value }) => serialize(value, Days)
|
43 |
+
)
|
44 |
+
days: any;
|
45 |
+
|
46 |
+
}
|
src/modules/console/modules/exercises/validations/create-excercise.validation.ts
CHANGED
@@ -63,7 +63,7 @@ export const createExerciseSchema = createSchema<ICreateExercise>({
|
|
63 |
"any.required": "benefits is required",
|
64 |
"string.empty": "benefits can not be empty",
|
65 |
}),
|
66 |
-
targetMuscles: joi.
|
67 |
"array.base": "please enter a valid target muscles",
|
68 |
"any.required": "target muscles is required",
|
69 |
}),
|
|
|
63 |
"any.required": "benefits is required",
|
64 |
"string.empty": "benefits can not be empty",
|
65 |
}),
|
66 |
+
targetMuscles: joi.object().empty().required().messages({
|
67 |
"array.base": "please enter a valid target muscles",
|
68 |
"any.required": "target muscles is required",
|
69 |
}),
|
src/modules/console/modules/ingredients/validations/create-ingredient.validation.ts
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as joi from "joi";
|
2 |
+
import { createSchema } from "@helpers/create-schema";
|
3 |
+
import { MealType } from "@common/enums/meal-type.enum";
|
4 |
+
|
5 |
+
|
6 |
+
export interface ICreateIngredients {
|
7 |
+
name: string;
|
8 |
+
serving_size: number;
|
9 |
+
servings_count: number;
|
10 |
+
serving_size_unit: string;
|
11 |
+
servings_count_unit: string;
|
12 |
+
calories: number;
|
13 |
+
carbs: number;
|
14 |
+
proteins: number;
|
15 |
+
fats: number;
|
16 |
+
}
|
17 |
+
|
18 |
+
export const createIngredientsSchema = createSchema<ICreateIngredients>({
|
19 |
+
name: joi.string().empty().required().messages({
|
20 |
+
"string.base": "please enter a valid name",
|
21 |
+
"any.required": "name is required",
|
22 |
+
"string.empty": "name can not be empty",
|
23 |
+
}),
|
24 |
+
serving_size: joi.number().empty().required().messages({
|
25 |
+
"number.base": "please enter a valid serving size",
|
26 |
+
"any.required": "serving size is required",
|
27 |
+
"number.empty": "serving size can not be empty",
|
28 |
+
}),
|
29 |
+
servings_count: joi.number().empty().required().messages({
|
30 |
+
"number.base": "please enter a valid servings count",
|
31 |
+
"any.required": "servings count is required",
|
32 |
+
"number.empty": "servings count can not be empty",
|
33 |
+
}),
|
34 |
+
serving_size_unit: joi.string().empty().required().messages({
|
35 |
+
"string.base": "please enter a valid serving size unit",
|
36 |
+
"any.required": "serving size unit is required",
|
37 |
+
"string.empty": "serving size unit can not be empty",
|
38 |
+
}),
|
39 |
+
servings_count_unit: joi.string().empty().required().messages({
|
40 |
+
"string.base": "please enter a valid servings count unit",
|
41 |
+
"any.required": "servings count unit is required",
|
42 |
+
"string.empty": "servings count unit can not be empty",
|
43 |
+
}),
|
44 |
+
calories: joi.number().empty().required().messages({
|
45 |
+
"number.base": "please enter a valid calories",
|
46 |
+
"any.required": "calories is required",
|
47 |
+
"number.empty": "calories can not be empty",
|
48 |
+
}),
|
49 |
+
carbs: joi.number().empty().required().messages({
|
50 |
+
"number.base": "please enter a valid carbs",
|
51 |
+
"any.required": "carbs is required",
|
52 |
+
"number.empty": "carbs can not be empty",
|
53 |
+
}),
|
54 |
+
proteins: joi.number().empty().required().messages({
|
55 |
+
"number.base": "please enter a valid proteins",
|
56 |
+
"any.required": "proteins is required",
|
57 |
+
"number.empty": "proteins can not be empty",
|
58 |
+
}),
|
59 |
+
fats: joi.number().empty().required().messages({
|
60 |
+
"number.base": "please enter a valid fats",
|
61 |
+
"any.required": "fats is required",
|
62 |
+
"number.empty": "fats can not be empty",
|
63 |
+
}),
|
64 |
+
});
|
src/modules/console/modules/ingredients/validations/update-ingredient.validation.ts
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as joi from "joi";
|
2 |
+
import { createSchema } from "@helpers/create-schema";
|
3 |
+
import { MealType } from "@common/enums/meal-type.enum";
|
4 |
+
|
5 |
+
|
6 |
+
export interface IUpdateIngredients {
|
7 |
+
name?: string;
|
8 |
+
serving_size?: number;
|
9 |
+
servings_count?: number;
|
10 |
+
serving_size_unit?: string;
|
11 |
+
servings_count_unit?: string;
|
12 |
+
calories?: number;
|
13 |
+
carbs?: number;
|
14 |
+
proteins?: number;
|
15 |
+
fats?: number;
|
16 |
+
}
|
17 |
+
|
18 |
+
export const updateIngredientsSchema = createSchema<IUpdateIngredients>({
|
19 |
+
name: joi.string().empty().optional().messages({
|
20 |
+
"string.base": "please enter a valid name",
|
21 |
+
"string.empty": "name can not be empty",
|
22 |
+
}),
|
23 |
+
serving_size: joi.number().empty().optional().messages({
|
24 |
+
"number.base": "please enter a valid serving size",
|
25 |
+
"number.empty": "serving size can not be empty",
|
26 |
+
}),
|
27 |
+
servings_count: joi.number().empty().optional().messages({
|
28 |
+
"number.base": "please enter a valid servings count",
|
29 |
+
"number.empty": "servings count can not be empty",
|
30 |
+
}),
|
31 |
+
serving_size_unit: joi.string().empty().optional().messages({
|
32 |
+
"string.base": "please enter a valid serving size unit",
|
33 |
+
"string.empty": "serving size unit can not be empty",
|
34 |
+
}),
|
35 |
+
servings_count_unit: joi.string().empty().optional().messages({
|
36 |
+
"string.base": "please enter a valid servings count unit",
|
37 |
+
"string.empty": "servings count unit can not be empty",
|
38 |
+
}),
|
39 |
+
calories: joi.number().empty().optional().messages({
|
40 |
+
"number.base": "please enter a valid calories",
|
41 |
+
"number.empty": "calories can not be empty",
|
42 |
+
}),
|
43 |
+
carbs: joi.number().empty().optional().messages({
|
44 |
+
"number.base": "please enter a valid carbs",
|
45 |
+
"number.empty": "carbs can not be empty",
|
46 |
+
}),
|
47 |
+
proteins: joi.number().empty().optional().messages({
|
48 |
+
"number.base": "please enter a valid proteins",
|
49 |
+
"number.empty": "proteins can not be empty",
|
50 |
+
}),
|
51 |
+
fats: joi.number().empty().optional().messages({
|
52 |
+
"number.base": "please enter a valid fats",
|
53 |
+
"number.empty": "fats can not be empty",
|
54 |
+
}),
|
55 |
+
});
|
src/modules/console/modules/meal-plans/validations/create-meal-plan.validation.ts
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { FitnessLevel } from "@common/enums/fitness-level.enum";
|
2 |
+
import * as joi from "joi";
|
3 |
+
import { createSchema } from "@helpers/create-schema";
|
4 |
+
|
5 |
+
export interface ICreateMealPlan {
|
6 |
+
image: string;
|
7 |
+
description: string;
|
8 |
+
Duration: number;
|
9 |
+
Level: FitnessLevel;
|
10 |
+
your_Journey: string;
|
11 |
+
key_Features: {
|
12 |
+
title: string;
|
13 |
+
description: string;
|
14 |
+
}[];
|
15 |
+
days: {
|
16 |
+
day_number: number;
|
17 |
+
meals: string[];
|
18 |
+
}[];
|
19 |
+
}
|
20 |
+
|
21 |
+
export const CreateMealPlanKeys = {
|
22 |
+
image: joi.string().empty().required().messages({
|
23 |
+
"string.base": "please enter a valid image",
|
24 |
+
"any.required": "image is required",
|
25 |
+
"string.empty": "image can not be empty",
|
26 |
+
}),
|
27 |
+
description: joi.string().empty().required().messages({
|
28 |
+
"string.base": "please enter a valid description",
|
29 |
+
"any.required": "description is required",
|
30 |
+
"string.empty": "description can not be empty",
|
31 |
+
}),
|
32 |
+
Duration: joi.number().empty().required().messages({
|
33 |
+
"number.base": "please enter a valid Duration",
|
34 |
+
"any.required": "Duration is required",
|
35 |
+
"number.empty": "Duration can not be empty",
|
36 |
+
}),
|
37 |
+
Level: joi.string().empty().required().messages({
|
38 |
+
"string.base": "please enter a valid Level",
|
39 |
+
"any.required": "Level is required",
|
40 |
+
"string.empty": "Level can not be empty",
|
41 |
+
}),
|
42 |
+
your_Journey: joi.string().empty().required().messages({
|
43 |
+
"string.base": "please enter a valid your_Journey",
|
44 |
+
"any.required": "your_Journey is required",
|
45 |
+
"string.empty": "your_Journey can not be empty",
|
46 |
+
}),
|
47 |
+
key_Features: joi.array().required().items(
|
48 |
+
joi.object({
|
49 |
+
title: joi.string().empty().required().messages({
|
50 |
+
"string.base": "please enter a valid title",
|
51 |
+
"any.required": "title is required",
|
52 |
+
"string.empty": "title can not be empty",
|
53 |
+
}),
|
54 |
+
description: joi.string().empty().required().messages({
|
55 |
+
"string.base": "please enter a valid description",
|
56 |
+
"any.required": "description is required",
|
57 |
+
"string.empty": "description can not be empty",
|
58 |
+
}),
|
59 |
+
}).required().empty().messages({
|
60 |
+
"any.required": "key_Features is required",
|
61 |
+
"object.empty": "key_Features can not be empty",
|
62 |
+
}),
|
63 |
+
).messages({
|
64 |
+
"array.base": "please enter a valid key_Features",
|
65 |
+
"any.required": "key_Features is required",
|
66 |
+
"array.empty": "key_Features can not be empty",
|
67 |
+
}),
|
68 |
+
days: joi.array().required().items(
|
69 |
+
joi.object({
|
70 |
+
day_number: joi.number().empty().required().messages({
|
71 |
+
"number.base": "please enter a valid day_number",
|
72 |
+
"any.required": "day_number is required",
|
73 |
+
"number.empty": "day_number can not be empty",
|
74 |
+
}),
|
75 |
+
meals: joi.array().items(
|
76 |
+
joi.string().empty().required().messages({
|
77 |
+
"string.base": "please enter a valid meals",
|
78 |
+
"any.required": "meals is required",
|
79 |
+
"string.empty": "meals can not be empty",
|
80 |
+
})
|
81 |
+
),
|
82 |
+
}).required().messages({
|
83 |
+
"any.required": "days is required",
|
84 |
+
"object.empty": "days can not be empty",
|
85 |
+
}),
|
86 |
+
).messages({
|
87 |
+
"array.base": "please enter a valid days",
|
88 |
+
"any.required": "days is required",
|
89 |
+
"array.empty": "days can not be empty",
|
90 |
+
}),
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
};
|
95 |
+
|
96 |
+
export const CreateMealPlan = createSchema<ICreateMealPlan>(CreateMealPlanKeys);
|
src/modules/console/modules/meal-plans/validations/update-meal-plan.validation.ts
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { FitnessLevel } from "@common/enums/fitness-level.enum";
|
2 |
+
import * as joi from "joi";
|
3 |
+
import { createSchema } from "@helpers/create-schema";
|
4 |
+
import { UpdateUserRegisteredMealPlan } from "modules/users/modules/user-registered-meal-plans/validations/update-user-registered-meal-plan.validation";
|
5 |
+
|
6 |
+
export interface IUpdateMealPlan {
|
7 |
+
image?: string;
|
8 |
+
description?: string;
|
9 |
+
Duration?: number;
|
10 |
+
Level?: FitnessLevel;
|
11 |
+
your_Journey?: string;
|
12 |
+
key_Features?: {
|
13 |
+
title?: string;
|
14 |
+
description?: string;
|
15 |
+
}[];
|
16 |
+
days?: {
|
17 |
+
day_number?: number;
|
18 |
+
meals?: string[];
|
19 |
+
}[];
|
20 |
+
}
|
21 |
+
|
22 |
+
export const UpdateMealPlanKeys = {
|
23 |
+
image: joi.string().empty().optional().messages({
|
24 |
+
"string.base": "please enter a valid image",
|
25 |
+
"any.required": "image is required",
|
26 |
+
"string.empty": "image can not be empty",
|
27 |
+
}),
|
28 |
+
description: joi.string().empty().optional().messages({
|
29 |
+
"string.base": "please enter a valid description",
|
30 |
+
"any.required": "description is required",
|
31 |
+
"string.empty": "description can not be empty",
|
32 |
+
}),
|
33 |
+
Duration: joi.number().empty().optional().messages({
|
34 |
+
"number.base": "please enter a valid Duration",
|
35 |
+
"any.required": "Duration is required",
|
36 |
+
"number.empty": "Duration can not be empty",
|
37 |
+
}),
|
38 |
+
Level: joi.string().empty().optional().messages({
|
39 |
+
"string.base": "please enter a valid Level",
|
40 |
+
"any.required": "Level is required",
|
41 |
+
"string.empty": "Level can not be empty",
|
42 |
+
}),
|
43 |
+
your_Journey: joi.string().empty().optional().messages({
|
44 |
+
"string.base": "please enter a valid your_Journey",
|
45 |
+
"any.required": "your_Journey is required",
|
46 |
+
"string.empty": "your_Journey can not be empty",
|
47 |
+
}),
|
48 |
+
key_Features: joi.array().optional().items(
|
49 |
+
joi.object({
|
50 |
+
title: joi.string().empty().optional().messages({
|
51 |
+
"string.base": "please enter a valid title",
|
52 |
+
"string.empty": "title can not be empty",
|
53 |
+
}),
|
54 |
+
description: joi.string().empty().optional().messages({
|
55 |
+
"string.base": "please enter a valid description",
|
56 |
+
"string.empty": "description can not be empty",
|
57 |
+
}),
|
58 |
+
}).optional().empty().messages({
|
59 |
+
"object.empty": "key_Features can not be empty",
|
60 |
+
}),
|
61 |
+
).messages({
|
62 |
+
"array.base": "please enter a valid key_Features",
|
63 |
+
"array.empty": "key_Features can not be empty",
|
64 |
+
}),
|
65 |
+
days: joi.array().optional().items(
|
66 |
+
joi.object({
|
67 |
+
day_number: joi.number().empty().optional().messages({
|
68 |
+
"number.base": "please enter a valid day_number",
|
69 |
+
"number.empty": "day_number can not be empty",
|
70 |
+
}),
|
71 |
+
meals: joi.array().items(
|
72 |
+
joi.string().empty().optional().messages({
|
73 |
+
"string.base": "please enter a valid meals",
|
74 |
+
"string.empty": "meals can not be empty",
|
75 |
+
})
|
76 |
+
),
|
77 |
+
}).optional().messages({
|
78 |
+
"object.empty": "days can not be empty",
|
79 |
+
}),
|
80 |
+
).messages({
|
81 |
+
"array.base": "please enter a valid days",
|
82 |
+
"array.empty": "days can not be empty",
|
83 |
+
}),
|
84 |
+
|
85 |
+
|
86 |
+
|
87 |
+
};
|
88 |
+
|
89 |
+
export const UpdateMealPlan = createSchema<IUpdateMealPlan>(UpdateMealPlanKeys);
|
src/modules/console/modules/meals/validations/create-meals.validation.ts
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as joi from "joi";
|
2 |
+
import { createSchema } from "@helpers/create-schema";
|
3 |
+
import { MealType } from "@common/enums/meal-type.enum";
|
4 |
+
|
5 |
+
export interface ICreateMeal {
|
6 |
+
name: string;
|
7 |
+
created_at?: Date;
|
8 |
+
ingredients: [string];
|
9 |
+
calories: number;
|
10 |
+
carbs: number;
|
11 |
+
proteins: number;
|
12 |
+
fats: number;
|
13 |
+
type: MealType;
|
14 |
+
}
|
15 |
+
|
16 |
+
export const createMealSchema = createSchema<ICreateMeal>({
|
17 |
+
name: joi.string().empty().required().messages({
|
18 |
+
"string.base": "please enter a valid name",
|
19 |
+
"any.required": "name is required",
|
20 |
+
"string.empty": "name can not be empty",
|
21 |
+
}),
|
22 |
+
created_at: joi.date().empty().optional().messages({
|
23 |
+
"date.base": "please enter a valid created_at",
|
24 |
+
"date.empty": "created_at can not be empty",
|
25 |
+
}),
|
26 |
+
ingredients: joi.array().items(joi.string()).required().messages({
|
27 |
+
"array.base": "please enter a valid ingredients",
|
28 |
+
"any.required": "ingredients is required",
|
29 |
+
}),
|
30 |
+
calories: joi.number().empty().required().messages({
|
31 |
+
"number.base": "please enter a valid calories",
|
32 |
+
"any.required": "calories is required",
|
33 |
+
"number.empty": "calories can not be empty",
|
34 |
+
}),
|
35 |
+
carbs: joi.number().empty().required().messages({
|
36 |
+
"number.base": "please enter a valid carbs",
|
37 |
+
"any.required": "carbs is required",
|
38 |
+
"number.empty": "carbs can not be empty",
|
39 |
+
}),
|
40 |
+
proteins: joi.number().empty().required().messages({
|
41 |
+
"number.base": "please enter a valid proteins",
|
42 |
+
"any.required": "proteins is required",
|
43 |
+
"number.empty": "proteins can not be empty",
|
44 |
+
}),
|
45 |
+
fats: joi.number().empty().required().messages({
|
46 |
+
"number.base": "please enter a valid fats",
|
47 |
+
"any.required": "fats is required",
|
48 |
+
"number.empty": "fats can not be empty",
|
49 |
+
}),
|
50 |
+
type: joi.string().empty().required().messages({
|
51 |
+
"string.base": "please enter a valid type",
|
52 |
+
"any.required": "type is required",
|
53 |
+
"string.empty": "type can not be empty",
|
54 |
+
}),
|
55 |
+
|
56 |
+
});
|
src/modules/console/modules/meals/validations/update-meals.validation.ts
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as joi from "joi";
|
2 |
+
import { createSchema } from "@helpers/create-schema";
|
3 |
+
import { MealType } from "@common/enums/meal-type.enum";
|
4 |
+
|
5 |
+
export interface IUpdateMeal {
|
6 |
+
name?: string;
|
7 |
+
created_at?: Date;
|
8 |
+
ingredients?: [string];
|
9 |
+
calories?: number;
|
10 |
+
carbs?: number;
|
11 |
+
proteins?: number;
|
12 |
+
fats?: number;
|
13 |
+
type?: MealType;
|
14 |
+
}
|
15 |
+
|
16 |
+
export const updateMealSchema = createSchema<IUpdateMeal>({
|
17 |
+
name: joi.string().empty().optional().messages({
|
18 |
+
"string.base": "please enter a valid name",
|
19 |
+
"string.empty": "name can not be empty",
|
20 |
+
}),
|
21 |
+
created_at: joi.date().empty().optional().messages({
|
22 |
+
"date.base": "please enter a valid created_at",
|
23 |
+
"date.empty": "created_at can not be empty",
|
24 |
+
}),
|
25 |
+
ingredients: joi.array().items(joi.string()).optional().messages({
|
26 |
+
"array.base": "please enter a valid ingredients",
|
27 |
+
}),
|
28 |
+
calories: joi.number().empty().optional().messages({
|
29 |
+
"number.base": "please enter a valid calories",
|
30 |
+
"number.empty": "calories can not be empty",
|
31 |
+
}),
|
32 |
+
carbs: joi.number().empty().optional().messages({
|
33 |
+
"number.base": "please enter a valid carbs",
|
34 |
+
"number.empty": "carbs can not be empty",
|
35 |
+
}),
|
36 |
+
proteins: joi.number().empty().optional().messages({
|
37 |
+
"number.base": "please enter a valid proteins",
|
38 |
+
"number.empty": "proteins can not be empty",
|
39 |
+
}),
|
40 |
+
fats: joi.number().empty().optional().messages({
|
41 |
+
"number.base": "please enter a valid fats",
|
42 |
+
"number.empty": "fats can not be empty",
|
43 |
+
}),
|
44 |
+
type: joi.string().empty().optional().messages({
|
45 |
+
"string.base": "please enter a valid type",
|
46 |
+
"string.empty": "type can not be empty",
|
47 |
+
}),
|
48 |
+
|
49 |
+
});
|
src/modules/users/modules/user-registered-meal-plans/validations/create-user-registered-meal-plan.validation.ts
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as joi from "joi";
|
2 |
+
import { createSchema } from "@helpers/create-schema";
|
3 |
+
|
4 |
+
export interface ICreateUserRegisteredMealPlan {
|
5 |
+
user: string;
|
6 |
+
isActive?: boolean;
|
7 |
+
meal_plan: string;
|
8 |
+
days: {
|
9 |
+
day_number: number;
|
10 |
+
meals: string[];
|
11 |
+
is_eaten?: boolean;
|
12 |
+
}[];
|
13 |
+
}
|
14 |
+
|
15 |
+
|
16 |
+
export const CreateUserRegisteredMealPlanKeys = {
|
17 |
+
user: joi.string().empty().required().messages({
|
18 |
+
"string.base": "please enter a valid user",
|
19 |
+
"any.required": "user is required",
|
20 |
+
"string.empty": "user can not be empty",
|
21 |
+
}),
|
22 |
+
isActive: joi.boolean().empty().optional().messages({
|
23 |
+
"boolean.base": "please enter a valid isActive",
|
24 |
+
"boolean.empty": "isActive can not be empty",
|
25 |
+
}),
|
26 |
+
meal_plan: joi.string().empty().required().messages({
|
27 |
+
"string.base": "please enter a valid meal_plan",
|
28 |
+
"any.required": "meal_plan is required",
|
29 |
+
"string.empty": "meal_plan can not be empty",
|
30 |
+
}),
|
31 |
+
days: joi.array().required().items(
|
32 |
+
joi.object({
|
33 |
+
day_number: joi.number().empty().required().messages({
|
34 |
+
"number.base": "please enter a valid day_number",
|
35 |
+
"any.required": "day_number is required",
|
36 |
+
"number.empty": "day_number can not be empty",
|
37 |
+
}),
|
38 |
+
meals: joi.array().items(
|
39 |
+
joi.string().empty().required().messages({
|
40 |
+
"string.base": "please enter a valid meals",
|
41 |
+
"any.required": "meals is required",
|
42 |
+
"string.empty": "meals can not be empty",
|
43 |
+
})
|
44 |
+
),
|
45 |
+
is_eaten: joi.boolean().empty().optional().messages({
|
46 |
+
"boolean.base": "please enter a valid is_eaten",
|
47 |
+
"boolean.empty": "is_eaten can not be empty",
|
48 |
+
}),
|
49 |
+
}).required().empty().messages({
|
50 |
+
"any.required": "days is required",
|
51 |
+
"object.empty": "days can not be empty",
|
52 |
+
}),
|
53 |
+
).messages({
|
54 |
+
"array.base": "please enter a valid days",
|
55 |
+
"any.required": "days is required",
|
56 |
+
"array.empty": "days can not be empty",
|
57 |
+
}),
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
+
};
|
62 |
+
|
63 |
+
export const CreateUserRegisteredMealPlan = createSchema<ICreateUserRegisteredMealPlan>(CreateUserRegisteredMealPlanKeys);
|
src/modules/users/modules/user-registered-meal-plans/validations/update-user-registered-meal-plan.validation.ts
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import * as joi from "joi";
|
2 |
+
import { createSchema } from "@helpers/create-schema";
|
3 |
+
|
4 |
+
export interface IUpdateUserRegisteredMealPlan {
|
5 |
+
user?: string;
|
6 |
+
isActive?: boolean;
|
7 |
+
meal_plan?: string;
|
8 |
+
days?: {
|
9 |
+
day_number?: number;
|
10 |
+
meals?: string[];
|
11 |
+
is_eaten?: boolean;
|
12 |
+
}[];
|
13 |
+
}
|
14 |
+
|
15 |
+
export const UpdateUserRegisteredMealPlanKeys = {
|
16 |
+
user: joi.string().empty().optional().messages({
|
17 |
+
"string.base": "please enter a valid user",
|
18 |
+
"string.empty": "user can not be empty",
|
19 |
+
}),
|
20 |
+
isActive: joi.boolean().empty().optional().messages({
|
21 |
+
"boolean.base": "please enter a valid isActive",
|
22 |
+
"boolean.empty": "isActive can not be empty",
|
23 |
+
}),
|
24 |
+
meal_plan: joi.string().empty().optional().messages({
|
25 |
+
"string.base": "please enter a valid meal_plan",
|
26 |
+
"string.empty": "meal_plan can not be empty",
|
27 |
+
}),
|
28 |
+
days: joi.array().optional().items(
|
29 |
+
joi.object({
|
30 |
+
day_number: joi.number().empty().optional().messages({
|
31 |
+
"number.base": "please enter a valid day_number",
|
32 |
+
"number.empty": "day_number can not be empty",
|
33 |
+
}),
|
34 |
+
meals: joi.array().items(
|
35 |
+
joi.string().empty().optional().messages({
|
36 |
+
"string.base": "please enter a valid meals",
|
37 |
+
"string.empty": "meals can not be empty",
|
38 |
+
})
|
39 |
+
),
|
40 |
+
is_eaten: joi.boolean().empty().optional().messages({
|
41 |
+
"boolean.base": "please enter a valid is_eaten",
|
42 |
+
"boolean.empty": "is_eaten can not be empty",
|
43 |
+
}),
|
44 |
+
}).optional().empty().messages({
|
45 |
+
"object.empty": "days can not be empty",
|
46 |
+
}),
|
47 |
+
).messages({
|
48 |
+
"array.base": "please enter a valid days",
|
49 |
+
"array.empty": "days can not be empty",
|
50 |
+
}),
|
51 |
+
|
52 |
+
};
|
53 |
+
|
54 |
+
export const UpdateUserRegisteredMealPlan = createSchema<IUpdateUserRegisteredMealPlan>(UpdateUserRegisteredMealPlanKeys);
|
src/modules/users/modules/workouts/controllers/workouts.controller.ts
CHANGED
@@ -15,7 +15,7 @@ import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
|
15 |
|
16 |
@Controller("/user/workouts")
|
17 |
@ControllerMiddleware(UsersGuardMiddleware())
|
18 |
-
export class
|
19 |
private workoutsService = new WorkoutService();
|
20 |
|
21 |
setRoutes(): void {
|
@@ -44,9 +44,13 @@ export class WorkoutController extends BaseController {
|
|
44 |
@SwaggerGet("/:id")
|
45 |
@SwaggerResponse(WorkoutSerialization)
|
46 |
get = async (req: Request, res: Response): Promise<Response> => {
|
47 |
-
const data = await this.workoutsService.findOneOrFail(
|
48 |
-
_id: req.params.id,
|
49 |
-
|
|
|
|
|
|
|
|
|
50 |
|
51 |
return JsonResponse.success(
|
52 |
{
|
|
|
15 |
|
16 |
@Controller("/user/workouts")
|
17 |
@ControllerMiddleware(UsersGuardMiddleware())
|
18 |
+
export class UsersWorkoutController extends BaseController {
|
19 |
private workoutsService = new WorkoutService();
|
20 |
|
21 |
setRoutes(): void {
|
|
|
44 |
@SwaggerGet("/:id")
|
45 |
@SwaggerResponse(WorkoutSerialization)
|
46 |
get = async (req: Request, res: Response): Promise<Response> => {
|
47 |
+
const data = await this.workoutsService.findOneOrFail(
|
48 |
+
{ _id: req.params.id },
|
49 |
+
{
|
50 |
+
populateArray: [
|
51 |
+
{ path: "template_weeks.days.exercises", select: "name media reps sets" },
|
52 |
+
],
|
53 |
+
});
|
54 |
|
55 |
return JsonResponse.success(
|
56 |
{
|