Spaces:
Running
Running
Hozifa Elgharbawy
commited on
Commit
·
339fa48
1
Parent(s):
d5d45a1
Update SwaggerResponseProperty types in serializers, add summary and description
Browse files- src/common/serializers/exercise.serialization.ts +11 -1
- src/common/serializers/exercisePopulate.serialization.ts +87 -0
- src/common/serializers/meal-plan.serialization.ts +2 -2
- src/common/serializers/meal-planPopulate.serialization.ts +66 -0
- src/common/serializers/meal.serialization.ts +1 -2
- src/common/serializers/mealPopulate.serialization.ts +38 -0
- src/common/serializers/templatePopulate.serialization.ts +25 -0
- src/common/serializers/user-registered-meal-plan.serialization.ts +1 -1
- src/common/serializers/user-registered-meal-planPopulate.serialization.ts +76 -0
- src/common/serializers/user-registered-workout.serialization.ts +3 -2
- src/common/serializers/user-registered-workoutPopulate.serialization.ts +74 -0
- src/common/serializers/workout.serialization.ts +1 -1
- src/common/serializers/workoutPopulate.serialization.ts +99 -0
- src/modules/console/modules/admins/controllers/admins.controller.ts +6 -7
- src/modules/console/modules/auth/controllers/auth.controller.ts +4 -0
- src/modules/console/modules/equipments/controllers/equipments.controller.ts +15 -4
- src/modules/console/modules/equipments/validations/create-equipment.validation.ts +1 -1
- src/modules/console/modules/exercises/controllers/exercises.controller.ts +35 -6
- src/modules/console/modules/ingredients/controller/ingredients.controller.ts +12 -0
- src/modules/console/modules/meal-plans/controller/meal-plans.controller.ts +32 -7
- src/modules/console/modules/meals/controller/meals.controller.ts +33 -8
- src/modules/console/modules/muscles/controllers/muscles.controller.ts +12 -0
- src/modules/console/modules/users/controllers/users.controller.ts +4 -0
- src/modules/console/modules/workouts/controllers/workouts.controller.ts +29 -8
- src/modules/users/modules/auth/controllers/auth.controller.ts +3 -0
- src/modules/users/modules/exercises/controllers/exercises.controller.ts +43 -16
- src/modules/users/modules/ingredients/controller/ingredients.controller.ts +1 -1
- src/modules/users/modules/meal-plans/controller/{meals.controller.ts → meal-plans.controller.ts} +5 -5
- src/modules/users/modules/meals/controller/meals.controller.ts +4 -4
- src/modules/users/modules/templates/controllers/templates.controller.ts +14 -10
- src/modules/users/modules/user-registered-meal-plans/controller/user-registered-meal-plans.controller.ts +7 -9
- src/modules/users/modules/user-registered-workouts/controllers/user-registered-workouts.controller.ts +24 -17
- src/modules/users/modules/users/controllers/users.controller.ts +6 -0
- src/modules/users/modules/workouts/controllers/workouts.controller.ts +10 -7
src/common/serializers/exercise.serialization.ts
CHANGED
@@ -22,6 +22,16 @@ class Media {
|
|
22 |
url: string;
|
23 |
}
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
export class ExerciseSerialization {
|
26 |
@Expose({ name: "_id" })
|
27 |
@SwaggerResponseProperty({ type: "string" })
|
@@ -61,7 +71,7 @@ export class ExerciseSerialization {
|
|
61 |
benefits: string;
|
62 |
|
63 |
@Expose()
|
64 |
-
@SwaggerResponseProperty({ type: [
|
65 |
targetMuscles: any;
|
66 |
|
67 |
@Expose()
|
|
|
22 |
url: string;
|
23 |
}
|
24 |
|
25 |
+
class TargetMuscles {
|
26 |
+
@Expose()
|
27 |
+
@SwaggerResponseProperty({ type: "string" })
|
28 |
+
primary: string;
|
29 |
+
|
30 |
+
@Expose()
|
31 |
+
@SwaggerResponseProperty({ type: "string" })
|
32 |
+
secondary: string;
|
33 |
+
}
|
34 |
+
|
35 |
export class ExerciseSerialization {
|
36 |
@Expose({ name: "_id" })
|
37 |
@SwaggerResponseProperty({ type: "string" })
|
|
|
71 |
benefits: string;
|
72 |
|
73 |
@Expose()
|
74 |
+
@SwaggerResponseProperty({ type: [TargetMuscles] })
|
75 |
targetMuscles: any;
|
76 |
|
77 |
@Expose()
|
src/common/serializers/exercisePopulate.serialization.ts
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Expose, Transform } from "class-transformer";
|
2 |
+
import { serialize } from "@helpers/serialize";
|
3 |
+
import { EquipmentSerialization } from "./muscle.serialization";
|
4 |
+
import { MuscleSerialization } from "./equipment.serialization";
|
5 |
+
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
6 |
+
|
7 |
+
class ExpectedDurationRangePopulate {
|
8 |
+
@Expose()
|
9 |
+
@SwaggerResponseProperty({ type: "number" })
|
10 |
+
min: number;
|
11 |
+
|
12 |
+
@Expose()
|
13 |
+
@SwaggerResponseProperty({ type: "number" })
|
14 |
+
max: number;
|
15 |
+
}
|
16 |
+
|
17 |
+
class MediaPopulate {
|
18 |
+
@Expose()
|
19 |
+
@SwaggerResponseProperty({ type: "string" })
|
20 |
+
type: string;
|
21 |
+
|
22 |
+
@Expose()
|
23 |
+
@SwaggerResponseProperty({ type: "string" })
|
24 |
+
url: string;
|
25 |
+
}
|
26 |
+
|
27 |
+
class TargetMusclesPopulate {
|
28 |
+
@Expose()
|
29 |
+
@SwaggerResponseProperty({ type: MuscleSerialization })
|
30 |
+
primary: string;
|
31 |
+
|
32 |
+
@Expose()
|
33 |
+
@SwaggerResponseProperty({ type: MuscleSerialization })
|
34 |
+
secondary: string;
|
35 |
+
}
|
36 |
+
|
37 |
+
export class ExercisePopulateSerialization {
|
38 |
+
@Expose({ name: "_id" })
|
39 |
+
@SwaggerResponseProperty({ type: "string" })
|
40 |
+
id: string;
|
41 |
+
|
42 |
+
@Expose()
|
43 |
+
@SwaggerResponseProperty({ type: "string" })
|
44 |
+
name: string;
|
45 |
+
|
46 |
+
@Expose()
|
47 |
+
@SwaggerResponseProperty({ type: "string" })
|
48 |
+
category: string;
|
49 |
+
|
50 |
+
@Expose()
|
51 |
+
@SwaggerResponseProperty({ type: "number" })
|
52 |
+
duration: number | null;
|
53 |
+
|
54 |
+
@Expose({ name: "expectedDurationRange" })
|
55 |
+
@SwaggerResponseProperty({ type: ExpectedDurationRangePopulate })
|
56 |
+
@Transform(({ value }) => serialize(value, ExpectedDurationRangePopulate))
|
57 |
+
expectedDurationRange: object;
|
58 |
+
|
59 |
+
@Expose()
|
60 |
+
@SwaggerResponseProperty({ type: "number" })
|
61 |
+
reps: number;
|
62 |
+
|
63 |
+
@Expose()
|
64 |
+
@SwaggerResponseProperty({ type: "number" })
|
65 |
+
sets: number;
|
66 |
+
|
67 |
+
@Expose()
|
68 |
+
@SwaggerResponseProperty({ type: "string" })
|
69 |
+
instructions: string;
|
70 |
+
|
71 |
+
@Expose()
|
72 |
+
@SwaggerResponseProperty({ type: "string" })
|
73 |
+
benefits: string;
|
74 |
+
|
75 |
+
@Expose()
|
76 |
+
@SwaggerResponseProperty({ type: [TargetMusclesPopulate] })
|
77 |
+
targetMuscles: any;
|
78 |
+
|
79 |
+
@Expose()
|
80 |
+
@SwaggerResponseProperty({ type: [EquipmentSerialization] })
|
81 |
+
equipments: any;
|
82 |
+
|
83 |
+
@Expose({ name: "media" })
|
84 |
+
@SwaggerResponseProperty({ type: MediaPopulate })
|
85 |
+
@Transform(({ value }) => serialize(value, MediaPopulate))
|
86 |
+
media: object;
|
87 |
+
}
|
src/common/serializers/meal-plan.serialization.ts
CHANGED
@@ -9,7 +9,7 @@ class MealPlanDays {
|
|
9 |
title: string;
|
10 |
|
11 |
@Expose({ name: "meals" })
|
12 |
-
@SwaggerResponseProperty({ type:
|
13 |
meals: any;
|
14 |
}
|
15 |
|
@@ -19,7 +19,7 @@ class MealPlanKeyFeatures {
|
|
19 |
day_number: number;
|
20 |
|
21 |
@Expose({ name: "description" })
|
22 |
-
@SwaggerResponseProperty({ type:
|
23 |
description: any;
|
24 |
}
|
25 |
|
|
|
9 |
title: string;
|
10 |
|
11 |
@Expose({ name: "meals" })
|
12 |
+
@SwaggerResponseProperty({ type: ["string"] })
|
13 |
meals: any;
|
14 |
}
|
15 |
|
|
|
19 |
day_number: number;
|
20 |
|
21 |
@Expose({ name: "description" })
|
22 |
+
@SwaggerResponseProperty({ type: "string" })
|
23 |
description: any;
|
24 |
}
|
25 |
|
src/common/serializers/meal-planPopulate.serialization.ts
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Expose, Transform } from "class-transformer";
|
2 |
+
import { serialize } from "@helpers/serialize";
|
3 |
+
import { MealSerialization } from './meal.serialization';
|
4 |
+
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
5 |
+
|
6 |
+
|
7 |
+
class MealPlanDaysPopulate {
|
8 |
+
@Expose()
|
9 |
+
@SwaggerResponseProperty({ type: "string" })
|
10 |
+
title: string;
|
11 |
+
|
12 |
+
@Expose({ name: "meals" })
|
13 |
+
@SwaggerResponseProperty({ type: MealSerialization })
|
14 |
+
meals: any;
|
15 |
+
}
|
16 |
+
|
17 |
+
class MealPlanKeyFeaturesPopulate {
|
18 |
+
@Expose()
|
19 |
+
@SwaggerResponseProperty({ type: "number" })
|
20 |
+
day_number: number;
|
21 |
+
|
22 |
+
@Expose({ name: "description" })
|
23 |
+
@SwaggerResponseProperty({ type: "string" })
|
24 |
+
description: any;
|
25 |
+
}
|
26 |
+
|
27 |
+
export class MealPlanPopulateSerialization {
|
28 |
+
@Expose({ name: "_id" })
|
29 |
+
@SwaggerResponseProperty({ type: "string" })
|
30 |
+
id: string;
|
31 |
+
|
32 |
+
@Expose()
|
33 |
+
@SwaggerResponseProperty({ type: "string" })
|
34 |
+
image: string;
|
35 |
+
|
36 |
+
@Expose()
|
37 |
+
@SwaggerResponseProperty({ type: "string" })
|
38 |
+
description: string;
|
39 |
+
|
40 |
+
@Expose()
|
41 |
+
@SwaggerResponseProperty({ type: "string" })
|
42 |
+
Duration: string;
|
43 |
+
|
44 |
+
@Expose()
|
45 |
+
@SwaggerResponseProperty({ type: "string" })
|
46 |
+
Level: string;
|
47 |
+
|
48 |
+
@Expose()
|
49 |
+
@SwaggerResponseProperty({ type: "string" })
|
50 |
+
your_Journey: string;
|
51 |
+
|
52 |
+
@Expose({ name: "key_Features" })
|
53 |
+
@SwaggerResponseProperty({ type: [MealPlanKeyFeaturesPopulate] })
|
54 |
+
@Transform(
|
55 |
+
({ value }) => serialize(value, MealPlanKeyFeaturesPopulate)
|
56 |
+
)
|
57 |
+
key_Features: any;
|
58 |
+
|
59 |
+
@Expose({ name: "days" })
|
60 |
+
@SwaggerResponseProperty({ type: [MealPlanDaysPopulate] })
|
61 |
+
@Transform(
|
62 |
+
({ value }) => serialize(value, MealPlanDaysPopulate)
|
63 |
+
)
|
64 |
+
days: any;
|
65 |
+
|
66 |
+
}
|
src/common/serializers/meal.serialization.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import { Expose } from "class-transformer";
|
2 |
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
3 |
-
import { IngredientSerialization } from "./ingredient.serialization";
|
4 |
|
5 |
|
6 |
export class MealSerialization {
|
@@ -13,7 +12,7 @@ export class MealSerialization {
|
|
13 |
created_at: Date;
|
14 |
|
15 |
@Expose()
|
16 |
-
@SwaggerResponseProperty({ type: [
|
17 |
ingredients: any;
|
18 |
|
19 |
@Expose()
|
|
|
1 |
import { Expose } from "class-transformer";
|
2 |
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
|
|
3 |
|
4 |
|
5 |
export class MealSerialization {
|
|
|
12 |
created_at: Date;
|
13 |
|
14 |
@Expose()
|
15 |
+
@SwaggerResponseProperty({ type: ["string"] })
|
16 |
ingredients: any;
|
17 |
|
18 |
@Expose()
|
src/common/serializers/mealPopulate.serialization.ts
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Expose } from "class-transformer";
|
2 |
+
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
3 |
+
import { IngredientSerialization } from "./ingredient.serialization";
|
4 |
+
|
5 |
+
|
6 |
+
export class MealPopulateSerialization {
|
7 |
+
@Expose()
|
8 |
+
@SwaggerResponseProperty({ type: "string" })
|
9 |
+
name: string;
|
10 |
+
|
11 |
+
@Expose()
|
12 |
+
@SwaggerResponseProperty({ type: "string" })
|
13 |
+
created_at: Date;
|
14 |
+
|
15 |
+
@Expose()
|
16 |
+
@SwaggerResponseProperty({ type: [IngredientSerialization] })
|
17 |
+
ingredients: any;
|
18 |
+
|
19 |
+
@Expose()
|
20 |
+
@SwaggerResponseProperty({ type: "number" })
|
21 |
+
calories: number;
|
22 |
+
|
23 |
+
@Expose()
|
24 |
+
@SwaggerResponseProperty({ type: "number" })
|
25 |
+
carbs: number;
|
26 |
+
|
27 |
+
@Expose()
|
28 |
+
@SwaggerResponseProperty({ type: "number" })
|
29 |
+
proteins: number;
|
30 |
+
|
31 |
+
@Expose()
|
32 |
+
@SwaggerResponseProperty({ type: "number" })
|
33 |
+
fats: number;
|
34 |
+
|
35 |
+
@Expose()
|
36 |
+
@SwaggerResponseProperty({ type: "string" })
|
37 |
+
type: string;
|
38 |
+
}
|
src/common/serializers/templatePopulate.serialization.ts
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
2 |
+
import { Expose } from "class-transformer";
|
3 |
+
import { ExerciseSerialization } from "./exercise.serialization";
|
4 |
+
|
5 |
+
export class TemplatePopulateSerialization {
|
6 |
+
@Expose({ name: "_id" })
|
7 |
+
@SwaggerResponseProperty({ type: "string" })
|
8 |
+
id: string;
|
9 |
+
|
10 |
+
@Expose()
|
11 |
+
@SwaggerResponseProperty({ type: "string" })
|
12 |
+
name: string;
|
13 |
+
|
14 |
+
@Expose()
|
15 |
+
@SwaggerResponseProperty({ type: "string" })
|
16 |
+
user: string;
|
17 |
+
|
18 |
+
@Expose()
|
19 |
+
@SwaggerResponseProperty({ type: "Date" })
|
20 |
+
creationDate: Date;
|
21 |
+
|
22 |
+
@Expose()
|
23 |
+
@SwaggerResponseProperty({ type: [ExerciseSerialization] })
|
24 |
+
exercises: any;
|
25 |
+
}
|
src/common/serializers/user-registered-meal-plan.serialization.ts
CHANGED
@@ -10,7 +10,7 @@ class MealDays {
|
|
10 |
day_number: number;
|
11 |
|
12 |
@Expose({ name: "meals" })
|
13 |
-
@SwaggerResponseProperty({ type:
|
14 |
meals: any;
|
15 |
|
16 |
@Expose()
|
|
|
10 |
day_number: number;
|
11 |
|
12 |
@Expose({ name: "meals" })
|
13 |
+
@SwaggerResponseProperty({ type: ["string"] })
|
14 |
meals: any;
|
15 |
|
16 |
@Expose()
|
src/common/serializers/user-registered-meal-planPopulate.serialization.ts
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Expose, Transform } from "class-transformer";
|
2 |
+
import { serialize } from "@helpers/serialize";
|
3 |
+
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
4 |
+
import { MealSerialization } from "./meal.serialization";
|
5 |
+
import { MealPlanSerialization } from "./meal-plan.serialization";
|
6 |
+
import { UserSerialization } from "./user.serialization";
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
class MealDaysPopulate {
|
11 |
+
@Expose()
|
12 |
+
@SwaggerResponseProperty({ type: "number" })
|
13 |
+
day_number: number;
|
14 |
+
|
15 |
+
@Expose({ name: "meals" })
|
16 |
+
@SwaggerResponseProperty({ type: [MealSerialization] })
|
17 |
+
meals: any;
|
18 |
+
|
19 |
+
@Expose()
|
20 |
+
@SwaggerResponseProperty({ type: "boolean" })
|
21 |
+
is_eaten: boolean;
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
export class UserRegisteredMealPlansPopulateSerialization {
|
26 |
+
@Expose({ name: "_id" })
|
27 |
+
@SwaggerResponseProperty({ type: "string" })
|
28 |
+
id: string;
|
29 |
+
|
30 |
+
@Expose()
|
31 |
+
@SwaggerResponseProperty({ type: "string" })
|
32 |
+
user: string;
|
33 |
+
|
34 |
+
@Expose()
|
35 |
+
@SwaggerResponseProperty({ type: MealPlanSerialization })
|
36 |
+
meal_plan: string;
|
37 |
+
|
38 |
+
@Expose()
|
39 |
+
@SwaggerResponseProperty({ type: "boolean" })
|
40 |
+
isActive: boolean;
|
41 |
+
|
42 |
+
@Expose({ name: "days" })
|
43 |
+
@SwaggerResponseProperty({ type: [MealDaysPopulate] })
|
44 |
+
@Transform(
|
45 |
+
({ value }) => serialize(value, MealDaysPopulate)
|
46 |
+
)
|
47 |
+
days: any;
|
48 |
+
|
49 |
+
}
|
50 |
+
|
51 |
+
|
52 |
+
export class UserRegisteredMealPlansPopulateUserSerialization {
|
53 |
+
@Expose({ name: "_id" })
|
54 |
+
@SwaggerResponseProperty({ type: "string" })
|
55 |
+
id: string;
|
56 |
+
|
57 |
+
@Expose()
|
58 |
+
@SwaggerResponseProperty({ type: UserSerialization })
|
59 |
+
user: string;
|
60 |
+
|
61 |
+
@Expose()
|
62 |
+
@SwaggerResponseProperty({ type: MealPlanSerialization })
|
63 |
+
meal_plan: string;
|
64 |
+
|
65 |
+
@Expose()
|
66 |
+
@SwaggerResponseProperty({ type: "boolean" })
|
67 |
+
isActive: boolean;
|
68 |
+
|
69 |
+
@Expose({ name: "days" })
|
70 |
+
@SwaggerResponseProperty({ type: [MealDaysPopulate] })
|
71 |
+
@Transform(
|
72 |
+
({ value }) => serialize(value, MealDaysPopulate)
|
73 |
+
)
|
74 |
+
days: any;
|
75 |
+
|
76 |
+
}
|
src/common/serializers/user-registered-workout.serialization.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import { Expose, Transform } from "class-transformer";
|
2 |
import { serialize } from "@helpers/serialize";
|
3 |
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
4 |
-
import { ExerciseSerialization } from "./exercise.serialization";
|
5 |
|
6 |
class MyWorkoutDays {
|
7 |
@Expose()
|
@@ -17,7 +16,7 @@ class MyWorkoutDays {
|
|
17 |
day_type: string;
|
18 |
|
19 |
@Expose({ name: "exercises" })
|
20 |
-
@SwaggerResponseProperty({ type: [
|
21 |
exercises: any;
|
22 |
|
23 |
@Expose()
|
@@ -70,3 +69,5 @@ export class UserRegisteredWorkoutsSerialization {
|
|
70 |
@Transform(({ value }) => serialize(value, MyWorkoutWeeks))
|
71 |
weeks: any;
|
72 |
}
|
|
|
|
|
|
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 |
class MyWorkoutDays {
|
6 |
@Expose()
|
|
|
16 |
day_type: string;
|
17 |
|
18 |
@Expose({ name: "exercises" })
|
19 |
+
@SwaggerResponseProperty({ type: ["string"] })
|
20 |
exercises: any;
|
21 |
|
22 |
@Expose()
|
|
|
69 |
@Transform(({ value }) => serialize(value, MyWorkoutWeeks))
|
70 |
weeks: any;
|
71 |
}
|
72 |
+
|
73 |
+
|
src/common/serializers/user-registered-workoutPopulate.serialization.ts
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Expose, Transform } from "class-transformer";
|
2 |
+
import { serialize } from "@helpers/serialize";
|
3 |
+
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
4 |
+
import { ExerciseSerialization } from "./exercise.serialization";
|
5 |
+
import { WorkoutSerialization } from "./workout.serialization";
|
6 |
+
|
7 |
+
|
8 |
+
class MyWorkoutDaysPopulate {
|
9 |
+
@Expose()
|
10 |
+
@SwaggerResponseProperty({ type: "number" })
|
11 |
+
day_number: number;
|
12 |
+
|
13 |
+
@Expose()
|
14 |
+
@SwaggerResponseProperty({ type: "number" })
|
15 |
+
total_number_exercises: number;
|
16 |
+
|
17 |
+
@Expose()
|
18 |
+
@SwaggerResponseProperty({ type: "string" })
|
19 |
+
day_type: string;
|
20 |
+
|
21 |
+
@Expose({ name: "exercises" })
|
22 |
+
@SwaggerResponseProperty({ type: [ExerciseSerialization] })
|
23 |
+
exercises: any;
|
24 |
+
|
25 |
+
@Expose()
|
26 |
+
@SwaggerResponseProperty({ type: "boolean" })
|
27 |
+
is_done: Boolean;
|
28 |
+
}
|
29 |
+
|
30 |
+
class MyWorkoutWeeksPopulate {
|
31 |
+
@Expose()
|
32 |
+
@SwaggerResponseProperty({ type: "number" })
|
33 |
+
week_number: number;
|
34 |
+
|
35 |
+
@Expose()
|
36 |
+
@SwaggerResponseProperty({ type: "string" })
|
37 |
+
week_name: string;
|
38 |
+
|
39 |
+
@Expose()
|
40 |
+
@SwaggerResponseProperty({ type: "string" })
|
41 |
+
week_description: string;
|
42 |
+
|
43 |
+
@Expose({ name: "days" })
|
44 |
+
@SwaggerResponseProperty({ type: [MyWorkoutDaysPopulate] })
|
45 |
+
@Transform(({ value }) => serialize(value, MyWorkoutDaysPopulate))
|
46 |
+
days: any;
|
47 |
+
|
48 |
+
@Expose()
|
49 |
+
@SwaggerResponseProperty({ type: "boolean" })
|
50 |
+
is_done: Boolean;
|
51 |
+
}
|
52 |
+
|
53 |
+
export class UserRegisteredWorkoutsPopulateSerialization {
|
54 |
+
@Expose({ name: "_id" })
|
55 |
+
@SwaggerResponseProperty({ type: "string" })
|
56 |
+
id: string;
|
57 |
+
|
58 |
+
@Expose()
|
59 |
+
@SwaggerResponseProperty({ type: "string" })
|
60 |
+
user: string;
|
61 |
+
|
62 |
+
@Expose()
|
63 |
+
@SwaggerResponseProperty({ type: WorkoutSerialization })
|
64 |
+
workout: string;
|
65 |
+
|
66 |
+
@Expose()
|
67 |
+
@SwaggerResponseProperty({ type: "boolean" })
|
68 |
+
is_active: Boolean;
|
69 |
+
|
70 |
+
@Expose({ name: "weeks" })
|
71 |
+
@SwaggerResponseProperty({ type: [MyWorkoutWeeksPopulate] })
|
72 |
+
@Transform(({ value }) => serialize(value, MyWorkoutWeeksPopulate))
|
73 |
+
weeks: any;
|
74 |
+
}
|
src/common/serializers/workout.serialization.ts
CHANGED
@@ -18,7 +18,7 @@ class WorkoutDays {
|
|
18 |
day_type: string;
|
19 |
|
20 |
@Expose({ name: "exercises" })
|
21 |
-
@SwaggerResponseProperty({ type:
|
22 |
exercises: any;
|
23 |
}
|
24 |
|
|
|
18 |
day_type: string;
|
19 |
|
20 |
@Expose({ name: "exercises" })
|
21 |
+
@SwaggerResponseProperty({ type: ["string"] })
|
22 |
exercises: any;
|
23 |
}
|
24 |
|
src/common/serializers/workoutPopulate.serialization.ts
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Expose, Transform } from "class-transformer";
|
2 |
+
import { serialize } from "@helpers/serialize";
|
3 |
+
import { SwaggerResponseProperty } from "@lib/decorators/swagger-response-property.decorator";
|
4 |
+
import { ExerciseSerialization } from "./exercise.serialization";
|
5 |
+
|
6 |
+
|
7 |
+
|
8 |
+
class WorkoutDaysPopulate {
|
9 |
+
@Expose()
|
10 |
+
@SwaggerResponseProperty({ type: "number" })
|
11 |
+
day_number: number;
|
12 |
+
|
13 |
+
@Expose()
|
14 |
+
@SwaggerResponseProperty({ type: "number" })
|
15 |
+
total_number_exercises: number;
|
16 |
+
|
17 |
+
@Expose()
|
18 |
+
@SwaggerResponseProperty({ type: "string" })
|
19 |
+
day_type: string;
|
20 |
+
|
21 |
+
@Expose({ name: "exercises" })
|
22 |
+
@SwaggerResponseProperty({ type: [ExerciseSerialization] })
|
23 |
+
exercises: any;
|
24 |
+
}
|
25 |
+
|
26 |
+
class WorkoutTemplateWeeksPopulate {
|
27 |
+
@Expose()
|
28 |
+
@SwaggerResponseProperty({ type: "number" })
|
29 |
+
week_number: number;
|
30 |
+
|
31 |
+
@Expose()
|
32 |
+
@SwaggerResponseProperty({ type: "string" })
|
33 |
+
week_name: string;
|
34 |
+
|
35 |
+
@Expose()
|
36 |
+
@SwaggerResponseProperty({ type: "string" })
|
37 |
+
week_description: string;
|
38 |
+
|
39 |
+
@Expose({ name: "days" })
|
40 |
+
@SwaggerResponseProperty({ type: [WorkoutDaysPopulate] })
|
41 |
+
@Transform(
|
42 |
+
({ value }) => serialize(value, WorkoutDaysPopulate)
|
43 |
+
)
|
44 |
+
days: any;
|
45 |
+
}
|
46 |
+
|
47 |
+
export class WorkoutSerializationPopulate {
|
48 |
+
@Expose({ name: "_id" })
|
49 |
+
@SwaggerResponseProperty({ type: "string" })
|
50 |
+
id: string;
|
51 |
+
|
52 |
+
@Expose()
|
53 |
+
@SwaggerResponseProperty({ type: "string" })
|
54 |
+
name: string;
|
55 |
+
|
56 |
+
@Expose()
|
57 |
+
@SwaggerResponseProperty({ type: "string" })
|
58 |
+
description: string;
|
59 |
+
|
60 |
+
@Expose()
|
61 |
+
@SwaggerResponseProperty({ type: "string" })
|
62 |
+
type: string;
|
63 |
+
|
64 |
+
@Expose()
|
65 |
+
@SwaggerResponseProperty({ type: "string" })
|
66 |
+
image: string;
|
67 |
+
|
68 |
+
@Expose()
|
69 |
+
@SwaggerResponseProperty({ type: "string" })
|
70 |
+
created_by: string;
|
71 |
+
|
72 |
+
@Expose()
|
73 |
+
@SwaggerResponseProperty({ type: "string" })
|
74 |
+
fitness_level: string;
|
75 |
+
|
76 |
+
@Expose()
|
77 |
+
@SwaggerResponseProperty({ type: "string" })
|
78 |
+
fitness_goal: string;
|
79 |
+
|
80 |
+
@Expose()
|
81 |
+
@SwaggerResponseProperty({ type: "string" })
|
82 |
+
place: any;
|
83 |
+
|
84 |
+
@Expose()
|
85 |
+
@SwaggerResponseProperty({ type: "number" })
|
86 |
+
min_per_day: number;
|
87 |
+
|
88 |
+
@Expose()
|
89 |
+
@SwaggerResponseProperty({ type: "number" })
|
90 |
+
total_number_days: number;
|
91 |
+
|
92 |
+
@Expose({ name: "template_weeks" })
|
93 |
+
@SwaggerResponseProperty({ type: [WorkoutTemplateWeeksPopulate] })
|
94 |
+
@Transform(
|
95 |
+
({ value }) => serialize(value, WorkoutTemplateWeeksPopulate)
|
96 |
+
)
|
97 |
+
template_weeks: any;
|
98 |
+
|
99 |
+
}
|
src/modules/console/modules/admins/controllers/admins.controller.ts
CHANGED
@@ -26,7 +26,6 @@ import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
|
26 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
27 |
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
28 |
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
29 |
-
import { SwaggerQuery } from "@lib/decorators/swagger-query.decorator";
|
30 |
|
31 |
@Controller("/console/admins")
|
32 |
@ControllerMiddleware(AdminGuardMiddleware({ roles: [Role.SUPER_ADMIN] }))
|
@@ -56,8 +55,8 @@ export class AdminsController extends BaseController {
|
|
56 |
|
57 |
@SwaggerGet()
|
58 |
@SwaggerResponse([AdminSerialization])
|
59 |
-
@SwaggerSummary("List
|
60 |
-
@SwaggerDescription("List all admins")
|
61 |
list = async (
|
62 |
req: Request,
|
63 |
res: Response<IJSONSuccessResponse<AdminSerialization[]>>
|
@@ -79,8 +78,8 @@ export class AdminsController extends BaseController {
|
|
79 |
|
80 |
@SwaggerGet("/:id")
|
81 |
@SwaggerResponse(AdminSerialization)
|
82 |
-
@SwaggerSummary("Get admin
|
83 |
-
@SwaggerDescription("Get admin by id")
|
84 |
get = async (
|
85 |
req: Request<{ id: string }>,
|
86 |
res: Response<IJSONSuccessResponse<AdminSerialization>>
|
@@ -121,7 +120,7 @@ export class AdminsController extends BaseController {
|
|
121 |
@SwaggerResponse(AdminSerialization)
|
122 |
@SwaggerRequest(createAdminSchema)
|
123 |
@SwaggerSummary("Update admin")
|
124 |
-
@SwaggerDescription("Updates an admin")
|
125 |
update = async (
|
126 |
req: Request<{ id: string }, {}, ICreateAdmin>,
|
127 |
res: Response<IJSONSuccessResponse<AdminSerialization>>
|
@@ -144,7 +143,7 @@ export class AdminsController extends BaseController {
|
|
144 |
@SwaggerDelete("/:id")
|
145 |
@SwaggerResponse(AdminSerialization)
|
146 |
@SwaggerSummary("Delete admin")
|
147 |
-
@SwaggerDescription("
|
148 |
delete = async (
|
149 |
req: Request<{ id: string }>,
|
150 |
res: Response<IJSONSuccessResponse<AdminSerialization>>
|
|
|
26 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
27 |
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
28 |
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
|
|
29 |
|
30 |
@Controller("/console/admins")
|
31 |
@ControllerMiddleware(AdminGuardMiddleware({ roles: [Role.SUPER_ADMIN] }))
|
|
|
55 |
|
56 |
@SwaggerGet()
|
57 |
@SwaggerResponse([AdminSerialization])
|
58 |
+
@SwaggerSummary("List admins")
|
59 |
+
@SwaggerDescription("List all admins in the system")
|
60 |
list = async (
|
61 |
req: Request,
|
62 |
res: Response<IJSONSuccessResponse<AdminSerialization[]>>
|
|
|
78 |
|
79 |
@SwaggerGet("/:id")
|
80 |
@SwaggerResponse(AdminSerialization)
|
81 |
+
@SwaggerSummary("Get admin")
|
82 |
+
@SwaggerDescription("Get an admin by id")
|
83 |
get = async (
|
84 |
req: Request<{ id: string }>,
|
85 |
res: Response<IJSONSuccessResponse<AdminSerialization>>
|
|
|
120 |
@SwaggerResponse(AdminSerialization)
|
121 |
@SwaggerRequest(createAdminSchema)
|
122 |
@SwaggerSummary("Update admin")
|
123 |
+
@SwaggerDescription("Updates an admin by id")
|
124 |
update = async (
|
125 |
req: Request<{ id: string }, {}, ICreateAdmin>,
|
126 |
res: Response<IJSONSuccessResponse<AdminSerialization>>
|
|
|
143 |
@SwaggerDelete("/:id")
|
144 |
@SwaggerResponse(AdminSerialization)
|
145 |
@SwaggerSummary("Delete admin")
|
146 |
+
@SwaggerDescription("Delete an admin by id")
|
147 |
delete = async (
|
148 |
req: Request<{ id: string }>,
|
149 |
res: Response<IJSONSuccessResponse<AdminSerialization>>
|
src/modules/console/modules/auth/controllers/auth.controller.ts
CHANGED
@@ -11,6 +11,8 @@ import { AdminSerialization } from "modules/console/common/serializers/admin.ser
|
|
11 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
12 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
13 |
import { SwaggerPost } from "@lib/decorators/swagger-routes.decorator";
|
|
|
|
|
14 |
|
15 |
@Controller("/console/auth")
|
16 |
export class ConsoleAuthController extends BaseController {
|
@@ -27,6 +29,8 @@ export class ConsoleAuthController extends BaseController {
|
|
27 |
@SwaggerPost('/login')
|
28 |
@SwaggerRequest(loginValidationSchema)
|
29 |
@SwaggerResponse(AdminSerialization)
|
|
|
|
|
30 |
login = async (req: Request, res: Response): Promise<Response> => {
|
31 |
const { admin, token } = await this.authService.login(req.body);
|
32 |
|
|
|
11 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
12 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
13 |
import { SwaggerPost } from "@lib/decorators/swagger-routes.decorator";
|
14 |
+
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
15 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
16 |
|
17 |
@Controller("/console/auth")
|
18 |
export class ConsoleAuthController extends BaseController {
|
|
|
29 |
@SwaggerPost('/login')
|
30 |
@SwaggerRequest(loginValidationSchema)
|
31 |
@SwaggerResponse(AdminSerialization)
|
32 |
+
@SwaggerSummary("Login an admin")
|
33 |
+
@SwaggerDescription("Login an admin")
|
34 |
login = async (req: Request, res: Response): Promise<Response> => {
|
35 |
const { admin, token } = await this.authService.login(req.body);
|
36 |
|
src/modules/console/modules/equipments/controllers/equipments.controller.ts
CHANGED
@@ -9,7 +9,7 @@ import { serialize } from "@helpers/serialize";
|
|
9 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
10 |
import { AdminGuardMiddleware } from "modules/console/common/guards/admins.guard";
|
11 |
import { EquipmentsService } from "../services/equipments.service";
|
12 |
-
import {
|
13 |
import { updateEquipmentSchema } from "../validations/update-equipment.validation";
|
14 |
import { EquipmentSerialization } from "@common/serializers/muscle.serialization";
|
15 |
import {
|
@@ -20,7 +20,8 @@ import {
|
|
20 |
} from "@lib/decorators/swagger-routes.decorator";
|
21 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
22 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
23 |
-
|
|
|
24 |
@Controller("/console/equipments")
|
25 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
26 |
export class EquipmentsController extends BaseController {
|
@@ -31,7 +32,7 @@ export class EquipmentsController extends BaseController {
|
|
31 |
this.router.get("/:id", paramsValidator("id"), asyncHandler(this.get));
|
32 |
this.router.post(
|
33 |
"/",
|
34 |
-
bodyValidator(
|
35 |
asyncHandler(this.create)
|
36 |
);
|
37 |
this.router.patch(
|
@@ -49,6 +50,8 @@ export class EquipmentsController extends BaseController {
|
|
49 |
|
50 |
@SwaggerGet()
|
51 |
@SwaggerResponse([EquipmentSerialization])
|
|
|
|
|
52 |
list = async (req: Request, res: Response) => {
|
53 |
const paginationQuery = parsePaginationQuery(req.query);
|
54 |
const { docs, paginationData } = await this.equipmentsService.list(
|
@@ -67,6 +70,8 @@ export class EquipmentsController extends BaseController {
|
|
67 |
|
68 |
@SwaggerGet("/{id}")
|
69 |
@SwaggerResponse(EquipmentSerialization)
|
|
|
|
|
70 |
get = async (req: Request, res: Response) => {
|
71 |
const data = await this.equipmentsService.findOneOrFail({
|
72 |
_id: req.params.id,
|
@@ -81,7 +86,9 @@ export class EquipmentsController extends BaseController {
|
|
81 |
|
82 |
@SwaggerPost()
|
83 |
@SwaggerResponse(EquipmentSerialization)
|
84 |
-
@SwaggerRequest(
|
|
|
|
|
85 |
create = async (req: Request, res: Response) => {
|
86 |
const data = await this.equipmentsService.create(req.body);
|
87 |
return JsonResponse.success(
|
@@ -96,6 +103,8 @@ export class EquipmentsController extends BaseController {
|
|
96 |
@SwaggerPatch("/{id}")
|
97 |
@SwaggerResponse(EquipmentSerialization)
|
98 |
@SwaggerRequest(updateEquipmentSchema)
|
|
|
|
|
99 |
update = async (req: Request, res: Response) => {
|
100 |
const data = await this.equipmentsService.updateOne(
|
101 |
{ _id: req.params.id },
|
@@ -111,6 +120,8 @@ export class EquipmentsController extends BaseController {
|
|
111 |
|
112 |
@SwaggerDelete("/{id}")
|
113 |
@SwaggerResponse(EquipmentSerialization)
|
|
|
|
|
114 |
delete = async (req: Request, res: Response) => {
|
115 |
const data = await this.equipmentsService.deleteOne({ _id: req.params.id });
|
116 |
return JsonResponse.success(
|
|
|
9 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
10 |
import { AdminGuardMiddleware } from "modules/console/common/guards/admins.guard";
|
11 |
import { EquipmentsService } from "../services/equipments.service";
|
12 |
+
import { createEquipmentSchema } from "../validations/create-equipment.validation";
|
13 |
import { updateEquipmentSchema } from "../validations/update-equipment.validation";
|
14 |
import { EquipmentSerialization } from "@common/serializers/muscle.serialization";
|
15 |
import {
|
|
|
20 |
} from "@lib/decorators/swagger-routes.decorator";
|
21 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
22 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
23 |
+
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
24 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
25 |
@Controller("/console/equipments")
|
26 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
27 |
export class EquipmentsController extends BaseController {
|
|
|
32 |
this.router.get("/:id", paramsValidator("id"), asyncHandler(this.get));
|
33 |
this.router.post(
|
34 |
"/",
|
35 |
+
bodyValidator(createEquipmentSchema),
|
36 |
asyncHandler(this.create)
|
37 |
);
|
38 |
this.router.patch(
|
|
|
50 |
|
51 |
@SwaggerGet()
|
52 |
@SwaggerResponse([EquipmentSerialization])
|
53 |
+
@SwaggerSummary("List equipments")
|
54 |
+
@SwaggerDescription("List all equipments in the system")
|
55 |
list = async (req: Request, res: Response) => {
|
56 |
const paginationQuery = parsePaginationQuery(req.query);
|
57 |
const { docs, paginationData } = await this.equipmentsService.list(
|
|
|
70 |
|
71 |
@SwaggerGet("/{id}")
|
72 |
@SwaggerResponse(EquipmentSerialization)
|
73 |
+
@SwaggerSummary("Get equipment")
|
74 |
+
@SwaggerDescription("Get a single equipment by id")
|
75 |
get = async (req: Request, res: Response) => {
|
76 |
const data = await this.equipmentsService.findOneOrFail({
|
77 |
_id: req.params.id,
|
|
|
86 |
|
87 |
@SwaggerPost()
|
88 |
@SwaggerResponse(EquipmentSerialization)
|
89 |
+
@SwaggerRequest(createEquipmentSchema)
|
90 |
+
@SwaggerSummary("Create equipment")
|
91 |
+
@SwaggerDescription("Create a new equipment")
|
92 |
create = async (req: Request, res: Response) => {
|
93 |
const data = await this.equipmentsService.create(req.body);
|
94 |
return JsonResponse.success(
|
|
|
103 |
@SwaggerPatch("/{id}")
|
104 |
@SwaggerResponse(EquipmentSerialization)
|
105 |
@SwaggerRequest(updateEquipmentSchema)
|
106 |
+
@SwaggerSummary("Update equipment")
|
107 |
+
@SwaggerDescription("Update a equipment by id")
|
108 |
update = async (req: Request, res: Response) => {
|
109 |
const data = await this.equipmentsService.updateOne(
|
110 |
{ _id: req.params.id },
|
|
|
120 |
|
121 |
@SwaggerDelete("/{id}")
|
122 |
@SwaggerResponse(EquipmentSerialization)
|
123 |
+
@SwaggerSummary("Delete equipment")
|
124 |
+
@SwaggerDescription("Delete a equipment by id")
|
125 |
delete = async (req: Request, res: Response) => {
|
126 |
const data = await this.equipmentsService.deleteOne({ _id: req.params.id });
|
127 |
return JsonResponse.success(
|
src/modules/console/modules/equipments/validations/create-equipment.validation.ts
CHANGED
@@ -6,7 +6,7 @@ export interface ICreateEquipment{
|
|
6 |
image: string;
|
7 |
}
|
8 |
|
9 |
-
export const
|
10 |
name: joi.string().empty().required().messages({
|
11 |
"string.base": "please enter a valid name",
|
12 |
"any.required": "name is required",
|
|
|
6 |
image: string;
|
7 |
}
|
8 |
|
9 |
+
export const createEquipmentSchema = createSchema<ICreateEquipment>({
|
10 |
name: joi.string().empty().required().messages({
|
11 |
"string.base": "please enter a valid name",
|
12 |
"any.required": "name is required",
|
src/modules/console/modules/exercises/controllers/exercises.controller.ts
CHANGED
@@ -8,6 +8,7 @@ import { Controller } from "@lib/decorators/controller.decorator";
|
|
8 |
import { JsonResponse } from "@lib/responses/json-response";
|
9 |
import { AdminGuardMiddleware } from "modules/console/common/guards/admins.guard";
|
10 |
import { ExercisesService } from "../services/exercises.service";
|
|
|
11 |
import { Request, Response } from "express";
|
12 |
import { serialize } from "@helpers/serialize";
|
13 |
import { createExerciseSchema } from "../validations/create-excercise.validation";
|
@@ -15,6 +16,8 @@ import { updateExerciseSchema } from "../validations/update-excercise.validation
|
|
15 |
import { SwaggerDelete, SwaggerGet, SwaggerPatch, SwaggerPost } from "@lib/decorators/swagger-routes.decorator";
|
16 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
17 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
|
|
|
|
18 |
|
19 |
@Controller("/console/exercises")
|
20 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
@@ -43,12 +46,21 @@ export class ExercisesController extends BaseController {
|
|
43 |
}
|
44 |
|
45 |
@SwaggerGet()
|
46 |
-
@SwaggerResponse([
|
|
|
|
|
47 |
list = async (req: Request, res: Response) => {
|
48 |
const paginationQuery = parsePaginationQuery(req.query);
|
49 |
const { docs, paginationData } = await this.exercisesService.list(
|
50 |
{},
|
51 |
-
paginationQuery
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
);
|
53 |
|
54 |
return JsonResponse.success(
|
@@ -61,11 +73,22 @@ export class ExercisesController extends BaseController {
|
|
61 |
};
|
62 |
|
63 |
@SwaggerGet("/:id")
|
64 |
-
@SwaggerResponse(
|
|
|
|
|
65 |
get = async (req: Request, res: Response) => {
|
66 |
-
const data = await this.exercisesService.findOneOrFail(
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
return JsonResponse.success(
|
70 |
{
|
71 |
data: serialize(data.toJSON(), ExerciseSerialization),
|
@@ -77,6 +100,8 @@ export class ExercisesController extends BaseController {
|
|
77 |
@SwaggerPost()
|
78 |
@SwaggerResponse(ExerciseSerialization)
|
79 |
@SwaggerRequest(createExerciseSchema)
|
|
|
|
|
80 |
create = async (req: Request, res: Response) => {
|
81 |
const data = await this.exercisesService.create(req.body);
|
82 |
return JsonResponse.success(
|
@@ -90,6 +115,8 @@ export class ExercisesController extends BaseController {
|
|
90 |
@SwaggerPatch("/:id")
|
91 |
@SwaggerRequest(updateExerciseSchema)
|
92 |
@SwaggerResponse(ExerciseSerialization)
|
|
|
|
|
93 |
update = async (req: Request, res: Response) => {
|
94 |
const data = await this.exercisesService.updateOne(
|
95 |
{ _id: req.params.id },
|
@@ -105,6 +132,8 @@ export class ExercisesController extends BaseController {
|
|
105 |
|
106 |
@SwaggerDelete("/:id")
|
107 |
@SwaggerResponse({})
|
|
|
|
|
108 |
delete = async (req: Request, res: Response) => {
|
109 |
await this.exercisesService.deleteOne({ _id: req.params.id });
|
110 |
return JsonResponse.success({}, res);
|
|
|
8 |
import { JsonResponse } from "@lib/responses/json-response";
|
9 |
import { AdminGuardMiddleware } from "modules/console/common/guards/admins.guard";
|
10 |
import { ExercisesService } from "../services/exercises.service";
|
11 |
+
import { ExercisePopulateSerialization } from "@common/serializers/exercisePopulate.serialization";
|
12 |
import { Request, Response } from "express";
|
13 |
import { serialize } from "@helpers/serialize";
|
14 |
import { createExerciseSchema } from "../validations/create-excercise.validation";
|
|
|
16 |
import { SwaggerDelete, SwaggerGet, SwaggerPatch, SwaggerPost } from "@lib/decorators/swagger-routes.decorator";
|
17 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
18 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
19 |
+
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
20 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
21 |
|
22 |
@Controller("/console/exercises")
|
23 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
|
|
46 |
}
|
47 |
|
48 |
@SwaggerGet()
|
49 |
+
@SwaggerResponse([ExercisePopulateSerialization])
|
50 |
+
@SwaggerSummary("List exercises")
|
51 |
+
@SwaggerDescription("List all exercises in the system")
|
52 |
list = async (req: Request, res: Response) => {
|
53 |
const paginationQuery = parsePaginationQuery(req.query);
|
54 |
const { docs, paginationData } = await this.exercisesService.list(
|
55 |
{},
|
56 |
+
paginationQuery,
|
57 |
+
{
|
58 |
+
populateArray: [
|
59 |
+
{ path: "targetMuscles.primary" },
|
60 |
+
{ path: "targetMuscles.secondary" },
|
61 |
+
{ path: "equipment" },
|
62 |
+
],
|
63 |
+
}
|
64 |
);
|
65 |
|
66 |
return JsonResponse.success(
|
|
|
73 |
};
|
74 |
|
75 |
@SwaggerGet("/:id")
|
76 |
+
@SwaggerResponse(ExercisePopulateSerialization)
|
77 |
+
@SwaggerSummary("Get exercise")
|
78 |
+
@SwaggerDescription("Get a single exercise by id")
|
79 |
get = async (req: Request, res: Response) => {
|
80 |
+
const data = await this.exercisesService.findOneOrFail(
|
81 |
+
{
|
82 |
+
_id: req.params.id,
|
83 |
+
},
|
84 |
+
{
|
85 |
+
populateArray: [
|
86 |
+
{ path: "targetMuscles.primary" },
|
87 |
+
{ path: "targetMuscles.secondary" },
|
88 |
+
{ path: "equipment" },
|
89 |
+
],
|
90 |
+
}
|
91 |
+
);
|
92 |
return JsonResponse.success(
|
93 |
{
|
94 |
data: serialize(data.toJSON(), ExerciseSerialization),
|
|
|
100 |
@SwaggerPost()
|
101 |
@SwaggerResponse(ExerciseSerialization)
|
102 |
@SwaggerRequest(createExerciseSchema)
|
103 |
+
@SwaggerSummary("Create exercise")
|
104 |
+
@SwaggerDescription("Create a new exercise")
|
105 |
create = async (req: Request, res: Response) => {
|
106 |
const data = await this.exercisesService.create(req.body);
|
107 |
return JsonResponse.success(
|
|
|
115 |
@SwaggerPatch("/:id")
|
116 |
@SwaggerRequest(updateExerciseSchema)
|
117 |
@SwaggerResponse(ExerciseSerialization)
|
118 |
+
@SwaggerSummary("Update exercise")
|
119 |
+
@SwaggerDescription("Update a single exercise by id")
|
120 |
update = async (req: Request, res: Response) => {
|
121 |
const data = await this.exercisesService.updateOne(
|
122 |
{ _id: req.params.id },
|
|
|
132 |
|
133 |
@SwaggerDelete("/:id")
|
134 |
@SwaggerResponse({})
|
135 |
+
@SwaggerSummary("Delete exercise")
|
136 |
+
@SwaggerDescription("Delete a single exercise by id")
|
137 |
delete = async (req: Request, res: Response) => {
|
138 |
await this.exercisesService.deleteOne({ _id: req.params.id });
|
139 |
return JsonResponse.success({}, res);
|
src/modules/console/modules/ingredients/controller/ingredients.controller.ts
CHANGED
@@ -15,6 +15,8 @@ import { IngredientSerialization } from "@common/serializers/ingredient.serializ
|
|
15 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
16 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
17 |
import { SwaggerGet, SwaggerPost, SwaggerPatch, SwaggerDelete } from "@lib/decorators/swagger-routes.decorator";
|
|
|
|
|
18 |
|
19 |
@Controller("/console/ingredients")
|
20 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
@@ -42,6 +44,8 @@ export class AdminsIngredientsController extends BaseController {
|
|
42 |
|
43 |
@SwaggerGet()
|
44 |
@SwaggerResponse([IngredientSerialization])
|
|
|
|
|
45 |
list = async (req: Request, res: Response) => {
|
46 |
const paginationQuery = parsePaginationQuery(req.query);
|
47 |
const { docs, paginationData } = await this.ingredientsService.list(
|
@@ -60,6 +64,8 @@ export class AdminsIngredientsController extends BaseController {
|
|
60 |
|
61 |
@SwaggerGet('/:id')
|
62 |
@SwaggerResponse(IngredientSerialization)
|
|
|
|
|
63 |
get = async (req: Request, res: Response) => {
|
64 |
const data = await this.ingredientsService.findOneOrFail({
|
65 |
_id: req.params.id,
|
@@ -75,6 +81,8 @@ export class AdminsIngredientsController extends BaseController {
|
|
75 |
@SwaggerPost()
|
76 |
@SwaggerRequest(createIngredientsSchema)
|
77 |
@SwaggerResponse(IngredientSerialization)
|
|
|
|
|
78 |
create = async (req: Request, res: Response) => {
|
79 |
const data = await this.ingredientsService.create(req.body);
|
80 |
return JsonResponse.success(
|
@@ -89,6 +97,8 @@ export class AdminsIngredientsController extends BaseController {
|
|
89 |
@SwaggerPatch('/:id')
|
90 |
@SwaggerRequest(updateIngredientsSchema)
|
91 |
@SwaggerResponse(IngredientSerialization)
|
|
|
|
|
92 |
update = async (req: Request, res: Response) => {
|
93 |
const data = await this.ingredientsService.updateOne(
|
94 |
{ _id: req.params.id },
|
@@ -104,6 +114,8 @@ export class AdminsIngredientsController extends BaseController {
|
|
104 |
|
105 |
@SwaggerDelete('/:id')
|
106 |
@SwaggerResponse(IngredientSerialization)
|
|
|
|
|
107 |
delete = async (req: Request, res: Response) => {
|
108 |
const data = await this.ingredientsService.deleteOne({ _id: req.params.id });
|
109 |
return JsonResponse.success(
|
|
|
15 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
16 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
17 |
import { SwaggerGet, SwaggerPost, SwaggerPatch, SwaggerDelete } from "@lib/decorators/swagger-routes.decorator";
|
18 |
+
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
19 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
20 |
|
21 |
@Controller("/console/ingredients")
|
22 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
|
|
44 |
|
45 |
@SwaggerGet()
|
46 |
@SwaggerResponse([IngredientSerialization])
|
47 |
+
@SwaggerSummary("List ingredients")
|
48 |
+
@SwaggerDescription("List all ingredients in the system")
|
49 |
list = async (req: Request, res: Response) => {
|
50 |
const paginationQuery = parsePaginationQuery(req.query);
|
51 |
const { docs, paginationData } = await this.ingredientsService.list(
|
|
|
64 |
|
65 |
@SwaggerGet('/:id')
|
66 |
@SwaggerResponse(IngredientSerialization)
|
67 |
+
@SwaggerSummary('Get ingredient')
|
68 |
+
@SwaggerDescription('Get ingredient by id')
|
69 |
get = async (req: Request, res: Response) => {
|
70 |
const data = await this.ingredientsService.findOneOrFail({
|
71 |
_id: req.params.id,
|
|
|
81 |
@SwaggerPost()
|
82 |
@SwaggerRequest(createIngredientsSchema)
|
83 |
@SwaggerResponse(IngredientSerialization)
|
84 |
+
@SwaggerSummary('Create ingredient')
|
85 |
+
@SwaggerDescription('Create a new ingredient')
|
86 |
create = async (req: Request, res: Response) => {
|
87 |
const data = await this.ingredientsService.create(req.body);
|
88 |
return JsonResponse.success(
|
|
|
97 |
@SwaggerPatch('/:id')
|
98 |
@SwaggerRequest(updateIngredientsSchema)
|
99 |
@SwaggerResponse(IngredientSerialization)
|
100 |
+
@SwaggerSummary('Update ingredient')
|
101 |
+
@SwaggerDescription('Update an ingredient by id')
|
102 |
update = async (req: Request, res: Response) => {
|
103 |
const data = await this.ingredientsService.updateOne(
|
104 |
{ _id: req.params.id },
|
|
|
114 |
|
115 |
@SwaggerDelete('/:id')
|
116 |
@SwaggerResponse(IngredientSerialization)
|
117 |
+
@SwaggerSummary('Delete ingredient')
|
118 |
+
@SwaggerDescription('Delete an ingredient by id')
|
119 |
delete = async (req: Request, res: Response) => {
|
120 |
const data = await this.ingredientsService.deleteOne({ _id: req.params.id });
|
121 |
return JsonResponse.success(
|
src/modules/console/modules/meal-plans/controller/meal-plans.controller.ts
CHANGED
@@ -11,10 +11,13 @@ import { AdminGuardMiddleware } from "modules/console/common/guards/admins.guard
|
|
11 |
import { MealPlansService } from "../services/meal-plans.service";
|
12 |
import { CreateMealPlan } from "../validations/create-meal-plan.validation";
|
13 |
import { UpdateMealPlan } from "../validations/update-meal-plan.validation";
|
14 |
-
import { MealPlanSerialization } from "@common/serializers/meal-plan.serialization";
|
|
|
15 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
16 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
17 |
import { SwaggerGet, SwaggerPost, SwaggerPatch, SwaggerDelete } from "@lib/decorators/swagger-routes.decorator";
|
|
|
|
|
18 |
|
19 |
@Controller("/console/mealPlans")
|
20 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
@@ -41,12 +44,19 @@ export class AdminsMealPlansController extends BaseController {
|
|
41 |
}
|
42 |
|
43 |
@SwaggerGet()
|
44 |
-
@SwaggerResponse([
|
|
|
|
|
45 |
list = async (req: Request, res: Response) => {
|
46 |
const paginationQuery = parsePaginationQuery(req.query);
|
47 |
const { docs, paginationData } = await this.mealPlansService.list(
|
48 |
{},
|
49 |
-
paginationQuery
|
|
|
|
|
|
|
|
|
|
|
50 |
);
|
51 |
|
52 |
return JsonResponse.success(
|
@@ -59,11 +69,20 @@ export class AdminsMealPlansController extends BaseController {
|
|
59 |
};
|
60 |
|
61 |
@SwaggerGet('/:id')
|
62 |
-
@SwaggerResponse(
|
|
|
|
|
63 |
get = async (req: Request, res: Response) => {
|
64 |
-
const data = await this.mealPlansService.findOneOrFail(
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
return JsonResponse.success(
|
68 |
{
|
69 |
data: serialize(data.toJSON(), MealPlanSerialization),
|
@@ -75,6 +94,8 @@ export class AdminsMealPlansController extends BaseController {
|
|
75 |
@SwaggerPost()
|
76 |
@SwaggerRequest(CreateMealPlan)
|
77 |
@SwaggerResponse(MealPlanSerialization)
|
|
|
|
|
78 |
create = async (req: Request, res: Response) => {
|
79 |
const data = await this.mealPlansService.create(req.body);
|
80 |
return JsonResponse.success(
|
@@ -89,6 +110,8 @@ export class AdminsMealPlansController extends BaseController {
|
|
89 |
@SwaggerPatch('/:id')
|
90 |
@SwaggerRequest(UpdateMealPlan)
|
91 |
@SwaggerResponse(MealPlanSerialization)
|
|
|
|
|
92 |
update = async (req: Request, res: Response) => {
|
93 |
const data = await this.mealPlansService.updateOne(
|
94 |
{ _id: req.params.id },
|
@@ -104,6 +127,8 @@ export class AdminsMealPlansController extends BaseController {
|
|
104 |
|
105 |
@SwaggerDelete('/:id')
|
106 |
@SwaggerResponse(MealPlanSerialization)
|
|
|
|
|
107 |
delete = async (req: Request, res: Response) => {
|
108 |
const data = await this.mealPlansService.deleteOne({ _id: req.params.id });
|
109 |
return JsonResponse.success(
|
|
|
11 |
import { MealPlansService } from "../services/meal-plans.service";
|
12 |
import { CreateMealPlan } from "../validations/create-meal-plan.validation";
|
13 |
import { UpdateMealPlan } from "../validations/update-meal-plan.validation";
|
14 |
+
import { MealPlanSerialization } from "@common/serializers/meal-plan.serialization";
|
15 |
+
import { MealPlanPopulateSerialization } from "@common/serializers/meal-planPopulate.serialization";
|
16 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
17 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
18 |
import { SwaggerGet, SwaggerPost, SwaggerPatch, SwaggerDelete } from "@lib/decorators/swagger-routes.decorator";
|
19 |
+
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
20 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
21 |
|
22 |
@Controller("/console/mealPlans")
|
23 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
|
|
44 |
}
|
45 |
|
46 |
@SwaggerGet()
|
47 |
+
@SwaggerResponse([MealPlanPopulateSerialization])
|
48 |
+
@SwaggerSummary("List meal plans")
|
49 |
+
@SwaggerDescription("List all meal plans in the system")
|
50 |
list = async (req: Request, res: Response) => {
|
51 |
const paginationQuery = parsePaginationQuery(req.query);
|
52 |
const { docs, paginationData } = await this.mealPlansService.list(
|
53 |
{},
|
54 |
+
paginationQuery,
|
55 |
+
{
|
56 |
+
populateArray: [
|
57 |
+
{ path: "days.meals" }
|
58 |
+
],
|
59 |
+
}
|
60 |
);
|
61 |
|
62 |
return JsonResponse.success(
|
|
|
69 |
};
|
70 |
|
71 |
@SwaggerGet('/:id')
|
72 |
+
@SwaggerResponse(MealPlanPopulateSerialization)
|
73 |
+
@SwaggerSummary('Get meal plan')
|
74 |
+
@SwaggerDescription('Get meal plan by id')
|
75 |
get = async (req: Request, res: Response) => {
|
76 |
+
const data = await this.mealPlansService.findOneOrFail(
|
77 |
+
{
|
78 |
+
_id: req.params.id,
|
79 |
+
},
|
80 |
+
{
|
81 |
+
populateArray: [
|
82 |
+
{ path: "days.meals" }
|
83 |
+
],
|
84 |
+
}
|
85 |
+
);
|
86 |
return JsonResponse.success(
|
87 |
{
|
88 |
data: serialize(data.toJSON(), MealPlanSerialization),
|
|
|
94 |
@SwaggerPost()
|
95 |
@SwaggerRequest(CreateMealPlan)
|
96 |
@SwaggerResponse(MealPlanSerialization)
|
97 |
+
@SwaggerSummary('Create meal plan')
|
98 |
+
@SwaggerDescription('Create a new meal plan')
|
99 |
create = async (req: Request, res: Response) => {
|
100 |
const data = await this.mealPlansService.create(req.body);
|
101 |
return JsonResponse.success(
|
|
|
110 |
@SwaggerPatch('/:id')
|
111 |
@SwaggerRequest(UpdateMealPlan)
|
112 |
@SwaggerResponse(MealPlanSerialization)
|
113 |
+
@SwaggerSummary('Update meal plan')
|
114 |
+
@SwaggerDescription('Update a meal plan by id')
|
115 |
update = async (req: Request, res: Response) => {
|
116 |
const data = await this.mealPlansService.updateOne(
|
117 |
{ _id: req.params.id },
|
|
|
127 |
|
128 |
@SwaggerDelete('/:id')
|
129 |
@SwaggerResponse(MealPlanSerialization)
|
130 |
+
@SwaggerSummary('Delete meal plan')
|
131 |
+
@SwaggerDescription('Delete a meal plan by id')
|
132 |
delete = async (req: Request, res: Response) => {
|
133 |
const data = await this.mealPlansService.deleteOne({ _id: req.params.id });
|
134 |
return JsonResponse.success(
|
src/modules/console/modules/meals/controller/meals.controller.ts
CHANGED
@@ -12,9 +12,12 @@ import { MealsService } from "../services/meals.service";
|
|
12 |
import { createMealSchema } from "../validations/create-meals.validation";
|
13 |
import { updateMealSchema } from "../validations/update-meals.validation";
|
14 |
import { MealSerialization } from "@common/serializers/meal.serialization";
|
|
|
15 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
16 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
17 |
import { SwaggerGet, SwaggerPost, SwaggerPatch, SwaggerDelete } from "@lib/decorators/swagger-routes.decorator";
|
|
|
|
|
18 |
|
19 |
@Controller("/console/meals")
|
20 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
@@ -41,17 +44,24 @@ export class AdminsMealsController extends BaseController {
|
|
41 |
}
|
42 |
|
43 |
@SwaggerGet()
|
44 |
-
@SwaggerResponse([
|
|
|
|
|
45 |
list = async (req: Request, res: Response) => {
|
46 |
const paginationQuery = parsePaginationQuery(req.query);
|
47 |
const { docs, paginationData } = await this.mealsService.list(
|
48 |
{},
|
49 |
-
paginationQuery
|
|
|
|
|
|
|
|
|
|
|
50 |
);
|
51 |
|
52 |
return JsonResponse.success(
|
53 |
{
|
54 |
-
data: serialize(docs,
|
55 |
meta: paginationData,
|
56 |
},
|
57 |
res
|
@@ -59,14 +69,23 @@ export class AdminsMealsController extends BaseController {
|
|
59 |
};
|
60 |
|
61 |
@SwaggerGet('/:id')
|
62 |
-
@SwaggerResponse(
|
|
|
|
|
63 |
get = async (req: Request, res: Response) => {
|
64 |
-
const data = await this.mealsService.findOneOrFail(
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
return JsonResponse.success(
|
68 |
{
|
69 |
-
data: serialize(data.toJSON(),
|
70 |
},
|
71 |
res
|
72 |
);
|
@@ -75,6 +94,8 @@ export class AdminsMealsController extends BaseController {
|
|
75 |
@SwaggerPost()
|
76 |
@SwaggerRequest(createMealSchema)
|
77 |
@SwaggerResponse(MealSerialization)
|
|
|
|
|
78 |
create = async (req: Request, res: Response) => {
|
79 |
const data = await this.mealsService.create(req.body);
|
80 |
return JsonResponse.success(
|
@@ -89,6 +110,8 @@ export class AdminsMealsController extends BaseController {
|
|
89 |
@SwaggerPatch('/:id')
|
90 |
@SwaggerRequest(updateMealSchema)
|
91 |
@SwaggerResponse(MealSerialization)
|
|
|
|
|
92 |
update = async (req: Request, res: Response) => {
|
93 |
const data = await this.mealsService.updateOne(
|
94 |
{ _id: req.params.id },
|
@@ -104,6 +127,8 @@ export class AdminsMealsController extends BaseController {
|
|
104 |
|
105 |
@SwaggerDelete('/:id')
|
106 |
@SwaggerResponse(MealSerialization)
|
|
|
|
|
107 |
delete = async (req: Request, res: Response) => {
|
108 |
const data = await this.mealsService.deleteOne({ _id: req.params.id });
|
109 |
return JsonResponse.success(
|
|
|
12 |
import { createMealSchema } from "../validations/create-meals.validation";
|
13 |
import { updateMealSchema } from "../validations/update-meals.validation";
|
14 |
import { MealSerialization } from "@common/serializers/meal.serialization";
|
15 |
+
import { MealPopulateSerialization } from "@common/serializers/mealPopulate.serialization";
|
16 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
17 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
18 |
import { SwaggerGet, SwaggerPost, SwaggerPatch, SwaggerDelete } from "@lib/decorators/swagger-routes.decorator";
|
19 |
+
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
20 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
21 |
|
22 |
@Controller("/console/meals")
|
23 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
|
|
44 |
}
|
45 |
|
46 |
@SwaggerGet()
|
47 |
+
@SwaggerResponse([MealPopulateSerialization])
|
48 |
+
@SwaggerSummary("List meals")
|
49 |
+
@SwaggerDescription("List all meals in the system")
|
50 |
list = async (req: Request, res: Response) => {
|
51 |
const paginationQuery = parsePaginationQuery(req.query);
|
52 |
const { docs, paginationData } = await this.mealsService.list(
|
53 |
{},
|
54 |
+
paginationQuery,
|
55 |
+
{
|
56 |
+
populateArray: [
|
57 |
+
{ path: "ingredients" }
|
58 |
+
],
|
59 |
+
}
|
60 |
);
|
61 |
|
62 |
return JsonResponse.success(
|
63 |
{
|
64 |
+
data: serialize(docs, MealPopulateSerialization),
|
65 |
meta: paginationData,
|
66 |
},
|
67 |
res
|
|
|
69 |
};
|
70 |
|
71 |
@SwaggerGet('/:id')
|
72 |
+
@SwaggerResponse(MealPopulateSerialization)
|
73 |
+
@SwaggerSummary('Get meal')
|
74 |
+
@SwaggerDescription('Get meal by id')
|
75 |
get = async (req: Request, res: Response) => {
|
76 |
+
const data = await this.mealsService.findOneOrFail(
|
77 |
+
{
|
78 |
+
_id: req.params.id,
|
79 |
+
},
|
80 |
+
{
|
81 |
+
populateArray: [
|
82 |
+
{ path: "ingredients" }
|
83 |
+
],
|
84 |
+
}
|
85 |
+
);
|
86 |
return JsonResponse.success(
|
87 |
{
|
88 |
+
data: serialize(data.toJSON(), MealPopulateSerialization),
|
89 |
},
|
90 |
res
|
91 |
);
|
|
|
94 |
@SwaggerPost()
|
95 |
@SwaggerRequest(createMealSchema)
|
96 |
@SwaggerResponse(MealSerialization)
|
97 |
+
@SwaggerSummary('Create meal')
|
98 |
+
@SwaggerDescription('Create a new meal')
|
99 |
create = async (req: Request, res: Response) => {
|
100 |
const data = await this.mealsService.create(req.body);
|
101 |
return JsonResponse.success(
|
|
|
110 |
@SwaggerPatch('/:id')
|
111 |
@SwaggerRequest(updateMealSchema)
|
112 |
@SwaggerResponse(MealSerialization)
|
113 |
+
@SwaggerSummary('Update meal')
|
114 |
+
@SwaggerDescription('Update a meal by id')
|
115 |
update = async (req: Request, res: Response) => {
|
116 |
const data = await this.mealsService.updateOne(
|
117 |
{ _id: req.params.id },
|
|
|
127 |
|
128 |
@SwaggerDelete('/:id')
|
129 |
@SwaggerResponse(MealSerialization)
|
130 |
+
@SwaggerSummary('Delete meal')
|
131 |
+
@SwaggerDescription('Delete a meal by id')
|
132 |
delete = async (req: Request, res: Response) => {
|
133 |
const data = await this.mealsService.deleteOne({ _id: req.params.id });
|
134 |
return JsonResponse.success(
|
src/modules/console/modules/muscles/controllers/muscles.controller.ts
CHANGED
@@ -15,6 +15,8 @@ import { MuscleSerialization } from "@common/serializers/equipment.serialization
|
|
15 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
16 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
17 |
import { SwaggerGet, SwaggerPost, SwaggerPatch, SwaggerDelete } from "@lib/decorators/swagger-routes.decorator";
|
|
|
|
|
18 |
|
19 |
@Controller("/console/muscles")
|
20 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
@@ -42,6 +44,8 @@ export class MusclesController extends BaseController {
|
|
42 |
|
43 |
@SwaggerGet()
|
44 |
@SwaggerResponse([MuscleSerialization])
|
|
|
|
|
45 |
list = async (req: Request, res: Response) => {
|
46 |
const paginationQuery = parsePaginationQuery(req.query);
|
47 |
const { docs, paginationData } = await this.musclesService.list(
|
@@ -60,6 +64,8 @@ export class MusclesController extends BaseController {
|
|
60 |
|
61 |
@SwaggerGet('/:id')
|
62 |
@SwaggerResponse(MuscleSerialization)
|
|
|
|
|
63 |
get = async (req: Request, res: Response) => {
|
64 |
const data = await this.musclesService.findOneOrFail({
|
65 |
_id: req.params.id,
|
@@ -75,6 +81,8 @@ export class MusclesController extends BaseController {
|
|
75 |
@SwaggerPost()
|
76 |
@SwaggerRequest(createMusclechema)
|
77 |
@SwaggerResponse(MuscleSerialization)
|
|
|
|
|
78 |
create = async (req: Request, res: Response) => {
|
79 |
const data = await this.musclesService.create(req.body);
|
80 |
return JsonResponse.success(
|
@@ -89,6 +97,8 @@ export class MusclesController extends BaseController {
|
|
89 |
@SwaggerPatch('/:id')
|
90 |
@SwaggerRequest(updateMuscleSchema)
|
91 |
@SwaggerResponse(MuscleSerialization)
|
|
|
|
|
92 |
update = async (req: Request, res: Response) => {
|
93 |
const data = await this.musclesService.updateOne(
|
94 |
{ _id: req.params.id },
|
@@ -104,6 +114,8 @@ export class MusclesController extends BaseController {
|
|
104 |
|
105 |
@SwaggerDelete('/:id')
|
106 |
@SwaggerResponse(MuscleSerialization)
|
|
|
|
|
107 |
delete = async (req: Request, res: Response) => {
|
108 |
const data = await this.musclesService.deleteOne({ _id: req.params.id });
|
109 |
return JsonResponse.success(
|
|
|
15 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
16 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
17 |
import { SwaggerGet, SwaggerPost, SwaggerPatch, SwaggerDelete } from "@lib/decorators/swagger-routes.decorator";
|
18 |
+
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
19 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
20 |
|
21 |
@Controller("/console/muscles")
|
22 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
|
|
44 |
|
45 |
@SwaggerGet()
|
46 |
@SwaggerResponse([MuscleSerialization])
|
47 |
+
@SwaggerSummary("List muscles")
|
48 |
+
@SwaggerDescription("List all muscles in the system")
|
49 |
list = async (req: Request, res: Response) => {
|
50 |
const paginationQuery = parsePaginationQuery(req.query);
|
51 |
const { docs, paginationData } = await this.musclesService.list(
|
|
|
64 |
|
65 |
@SwaggerGet('/:id')
|
66 |
@SwaggerResponse(MuscleSerialization)
|
67 |
+
@SwaggerSummary("Get muscle")
|
68 |
+
@SwaggerDescription("Get muscle by id")
|
69 |
get = async (req: Request, res: Response) => {
|
70 |
const data = await this.musclesService.findOneOrFail({
|
71 |
_id: req.params.id,
|
|
|
81 |
@SwaggerPost()
|
82 |
@SwaggerRequest(createMusclechema)
|
83 |
@SwaggerResponse(MuscleSerialization)
|
84 |
+
@SwaggerSummary("Create muscle")
|
85 |
+
@SwaggerDescription("Create a new muscle")
|
86 |
create = async (req: Request, res: Response) => {
|
87 |
const data = await this.musclesService.create(req.body);
|
88 |
return JsonResponse.success(
|
|
|
97 |
@SwaggerPatch('/:id')
|
98 |
@SwaggerRequest(updateMuscleSchema)
|
99 |
@SwaggerResponse(MuscleSerialization)
|
100 |
+
@SwaggerSummary("Update muscle")
|
101 |
+
@SwaggerDescription("Update a muscle by id")
|
102 |
update = async (req: Request, res: Response) => {
|
103 |
const data = await this.musclesService.updateOne(
|
104 |
{ _id: req.params.id },
|
|
|
114 |
|
115 |
@SwaggerDelete('/:id')
|
116 |
@SwaggerResponse(MuscleSerialization)
|
117 |
+
@SwaggerSummary("Delete muscle")
|
118 |
+
@SwaggerDescription("Delete a muscle by id")
|
119 |
delete = async (req: Request, res: Response) => {
|
120 |
const data = await this.musclesService.deleteOne({ _id: req.params.id });
|
121 |
return JsonResponse.success(
|
src/modules/console/modules/users/controllers/users.controller.ts
CHANGED
@@ -8,6 +8,8 @@ import { serialize } from "@helpers/serialize";
|
|
8 |
import { UserSerialization } from "@common/serializers/user.serialization";
|
9 |
import { SwaggerPost } from "@lib/decorators/swagger-routes.decorator";
|
10 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
|
|
|
|
11 |
|
12 |
@Controller("/console/users")
|
13 |
export class AdminUsersController extends BaseController {
|
@@ -19,6 +21,8 @@ export class AdminUsersController extends BaseController {
|
|
19 |
|
20 |
@SwaggerPost("/create")
|
21 |
@SwaggerResponse(UserSerialization)
|
|
|
|
|
22 |
create = async (req: Request, res: Response): Promise<Response> => {
|
23 |
let user = await this.usersService.create(req.body);
|
24 |
|
|
|
8 |
import { UserSerialization } from "@common/serializers/user.serialization";
|
9 |
import { SwaggerPost } from "@lib/decorators/swagger-routes.decorator";
|
10 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
11 |
+
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
12 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
13 |
|
14 |
@Controller("/console/users")
|
15 |
export class AdminUsersController extends BaseController {
|
|
|
21 |
|
22 |
@SwaggerPost("/create")
|
23 |
@SwaggerResponse(UserSerialization)
|
24 |
+
@SwaggerSummary("Create user")
|
25 |
+
@SwaggerDescription("Create a new user")
|
26 |
create = async (req: Request, res: Response): Promise<Response> => {
|
27 |
let user = await this.usersService.create(req.body);
|
28 |
|
src/modules/console/modules/workouts/controllers/workouts.controller.ts
CHANGED
@@ -10,6 +10,7 @@ import { BaseController } from "@lib/controllers/controller.base";
|
|
10 |
import { Controller } from "@lib/decorators/controller.decorator";
|
11 |
import { serialize } from "@helpers/serialize";
|
12 |
import { WorkoutSerialization } from "@common/serializers/workout.serialization";
|
|
|
13 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
14 |
import { AdminGuardMiddleware } from "modules/console/common/guards/admins.guard";
|
15 |
import {
|
@@ -20,6 +21,8 @@ import {
|
|
20 |
} from "@lib/decorators/swagger-routes.decorator";
|
21 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
22 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
|
|
|
|
23 |
|
24 |
@Controller("/console/workouts")
|
25 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
@@ -48,17 +51,22 @@ export class WorkoutController extends BaseController {
|
|
48 |
}
|
49 |
|
50 |
@SwaggerGet()
|
51 |
-
@SwaggerResponse([
|
|
|
|
|
52 |
list = async (req: Request, res: Response) => {
|
53 |
const paginationQuery = parsePaginationQuery(req.query);
|
54 |
const { docs, paginationData } = await this.workoutsService.list(
|
55 |
{},
|
56 |
-
paginationQuery
|
|
|
|
|
|
|
57 |
);
|
58 |
|
59 |
return JsonResponse.success(
|
60 |
{
|
61 |
-
data: serialize(docs,
|
62 |
meta: paginationData,
|
63 |
},
|
64 |
res
|
@@ -66,14 +74,21 @@ export class WorkoutController extends BaseController {
|
|
66 |
};
|
67 |
|
68 |
@SwaggerGet("/:id")
|
69 |
-
@SwaggerResponse(
|
|
|
|
|
70 |
get = async (req: Request, res: Response) => {
|
71 |
-
const data = await this.workoutsService.findOneOrFail(
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
74 |
return JsonResponse.success(
|
75 |
{
|
76 |
-
data: serialize(data.toJSON(),
|
77 |
},
|
78 |
res
|
79 |
);
|
@@ -82,6 +97,8 @@ export class WorkoutController extends BaseController {
|
|
82 |
@SwaggerPost()
|
83 |
@SwaggerResponse(WorkoutSerialization)
|
84 |
@SwaggerRequest(createWorkoutSchema)
|
|
|
|
|
85 |
create = async (req: Request, res: Response) => {
|
86 |
const data = await this.workoutsService.create(req.body);
|
87 |
return JsonResponse.success(
|
@@ -96,6 +113,8 @@ export class WorkoutController extends BaseController {
|
|
96 |
@SwaggerPatch("/:id")
|
97 |
@SwaggerResponse(WorkoutSerialization)
|
98 |
@SwaggerRequest(updateWorkoutSchema)
|
|
|
|
|
99 |
update = async (req: Request, res: Response) => {
|
100 |
const data = await this.workoutsService.updateOne(
|
101 |
{ _id: req.params.id },
|
@@ -111,6 +130,8 @@ export class WorkoutController extends BaseController {
|
|
111 |
|
112 |
@SwaggerDelete("/:id")
|
113 |
@SwaggerResponse(WorkoutSerialization)
|
|
|
|
|
114 |
delete = async (req: Request, res: Response) => {
|
115 |
const data = await this.workoutsService.deleteOne({ _id: req.params.id });
|
116 |
return JsonResponse.success(
|
|
|
10 |
import { Controller } from "@lib/decorators/controller.decorator";
|
11 |
import { serialize } from "@helpers/serialize";
|
12 |
import { WorkoutSerialization } from "@common/serializers/workout.serialization";
|
13 |
+
import { WorkoutSerializationPopulate } from "@common/serializers/workoutPopulate.serialization";
|
14 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
15 |
import { AdminGuardMiddleware } from "modules/console/common/guards/admins.guard";
|
16 |
import {
|
|
|
21 |
} from "@lib/decorators/swagger-routes.decorator";
|
22 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
23 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
24 |
+
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
25 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
26 |
|
27 |
@Controller("/console/workouts")
|
28 |
@ControllerMiddleware(AdminGuardMiddleware({}))
|
|
|
51 |
}
|
52 |
|
53 |
@SwaggerGet()
|
54 |
+
@SwaggerResponse([WorkoutSerializationPopulate])
|
55 |
+
@SwaggerSummary("List workouts")
|
56 |
+
@SwaggerDescription("List all workouts in the system")
|
57 |
list = async (req: Request, res: Response) => {
|
58 |
const paginationQuery = parsePaginationQuery(req.query);
|
59 |
const { docs, paginationData } = await this.workoutsService.list(
|
60 |
{},
|
61 |
+
paginationQuery,
|
62 |
+
{
|
63 |
+
populateArray: [{ path: "exercises" }],
|
64 |
+
}
|
65 |
);
|
66 |
|
67 |
return JsonResponse.success(
|
68 |
{
|
69 |
+
data: serialize(docs, WorkoutSerializationPopulate),
|
70 |
meta: paginationData,
|
71 |
},
|
72 |
res
|
|
|
74 |
};
|
75 |
|
76 |
@SwaggerGet("/:id")
|
77 |
+
@SwaggerResponse(WorkoutSerializationPopulate)
|
78 |
+
@SwaggerSummary("Get workout")
|
79 |
+
@SwaggerDescription("Get workout by id")
|
80 |
get = async (req: Request, res: Response) => {
|
81 |
+
const data = await this.workoutsService.findOneOrFail(
|
82 |
+
{
|
83 |
+
_id: req.params.id,
|
84 |
+
},
|
85 |
+
{
|
86 |
+
populateArray: [{ path: "exercises" }],
|
87 |
+
}
|
88 |
+
);
|
89 |
return JsonResponse.success(
|
90 |
{
|
91 |
+
data: serialize(data.toJSON(), WorkoutSerializationPopulate),
|
92 |
},
|
93 |
res
|
94 |
);
|
|
|
97 |
@SwaggerPost()
|
98 |
@SwaggerResponse(WorkoutSerialization)
|
99 |
@SwaggerRequest(createWorkoutSchema)
|
100 |
+
@SwaggerSummary("Create workout")
|
101 |
+
@SwaggerDescription("Create a new workout")
|
102 |
create = async (req: Request, res: Response) => {
|
103 |
const data = await this.workoutsService.create(req.body);
|
104 |
return JsonResponse.success(
|
|
|
113 |
@SwaggerPatch("/:id")
|
114 |
@SwaggerResponse(WorkoutSerialization)
|
115 |
@SwaggerRequest(updateWorkoutSchema)
|
116 |
+
@SwaggerSummary("Update workout")
|
117 |
+
@SwaggerDescription("Update a workout by id")
|
118 |
update = async (req: Request, res: Response) => {
|
119 |
const data = await this.workoutsService.updateOne(
|
120 |
{ _id: req.params.id },
|
|
|
130 |
|
131 |
@SwaggerDelete("/:id")
|
132 |
@SwaggerResponse(WorkoutSerialization)
|
133 |
+
@SwaggerSummary("Delete workout")
|
134 |
+
@SwaggerDescription("Delete a workout by id")
|
135 |
delete = async (req: Request, res: Response) => {
|
136 |
const data = await this.workoutsService.deleteOne({ _id: req.params.id });
|
137 |
return JsonResponse.success(
|
src/modules/users/modules/auth/controllers/auth.controller.ts
CHANGED
@@ -16,6 +16,7 @@ import { SwaggerPost } from "@lib/decorators/swagger-routes.decorator";
|
|
16 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
17 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
18 |
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
|
|
19 |
|
20 |
@Controller("/user/auth")
|
21 |
export class UsersAuthController extends BaseController {
|
@@ -38,6 +39,7 @@ export class UsersAuthController extends BaseController {
|
|
38 |
@SwaggerRequest(userRegisterSchema)
|
39 |
@SwaggerResponse(UserSerialization)
|
40 |
@SwaggerSummary("Register a new user")
|
|
|
41 |
register = async (req: Request, res: Response) => {
|
42 |
const user = await this.authService.register(req.body as IUserRegister);
|
43 |
|
@@ -53,6 +55,7 @@ export class UsersAuthController extends BaseController {
|
|
53 |
@SwaggerRequest(loginValidationSchema)
|
54 |
@SwaggerResponse(UserSerialization)
|
55 |
@SwaggerSummary("Login a user")
|
|
|
56 |
login = async (req: Request, res: Response): Promise<Response> => {
|
57 |
const { user, token } = await this.authService.login(req.body);
|
58 |
|
|
|
16 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
17 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
18 |
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
19 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
20 |
|
21 |
@Controller("/user/auth")
|
22 |
export class UsersAuthController extends BaseController {
|
|
|
39 |
@SwaggerRequest(userRegisterSchema)
|
40 |
@SwaggerResponse(UserSerialization)
|
41 |
@SwaggerSummary("Register a new user")
|
42 |
+
@SwaggerDescription("Register a new user")
|
43 |
register = async (req: Request, res: Response) => {
|
44 |
const user = await this.authService.register(req.body as IUserRegister);
|
45 |
|
|
|
55 |
@SwaggerRequest(loginValidationSchema)
|
56 |
@SwaggerResponse(UserSerialization)
|
57 |
@SwaggerSummary("Login a user")
|
58 |
+
@SwaggerDescription("Login a user")
|
59 |
login = async (req: Request, res: Response): Promise<Response> => {
|
60 |
const { user, token } = await this.authService.login(req.body);
|
61 |
|
src/modules/users/modules/exercises/controllers/exercises.controller.ts
CHANGED
@@ -7,16 +7,17 @@ import { paramsValidator } from "@helpers/validation.helper";
|
|
7 |
import { BaseController } from "@lib/controllers/controller.base";
|
8 |
import { Controller } from "@lib/decorators/controller.decorator";
|
9 |
import { serialize } from "@helpers/serialize";
|
10 |
-
import {
|
11 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
12 |
import { UsersGuardMiddleware } from "modules/users/common/guards/users.guard";
|
13 |
import { SwaggerGet } from "@lib/decorators/swagger-routes.decorator";
|
14 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
15 |
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
|
|
16 |
|
17 |
@Controller("/user/exercises")
|
18 |
@ControllerMiddleware(UsersGuardMiddleware())
|
19 |
-
export class
|
20 |
private exercisesService = new ExerciseService();
|
21 |
|
22 |
setRoutes(): void {
|
@@ -26,18 +27,26 @@ export class ExerciseController extends BaseController {
|
|
26 |
}
|
27 |
|
28 |
@SwaggerGet()
|
29 |
-
@SwaggerResponse([
|
30 |
-
@SwaggerSummary("List
|
|
|
31 |
list = async (req: Request, res: Response): Promise<Response> => {
|
32 |
const paginationQuery = parsePaginationQuery(req.query);
|
33 |
const { docs, paginationData } = await this.exercisesService.list(
|
34 |
{},
|
35 |
-
paginationQuery
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
);
|
37 |
|
38 |
return JsonResponse.success(
|
39 |
{
|
40 |
-
data: serialize(docs,
|
41 |
meta: paginationData,
|
42 |
},
|
43 |
res
|
@@ -45,24 +54,35 @@ export class ExerciseController extends BaseController {
|
|
45 |
};
|
46 |
|
47 |
@SwaggerGet("/:id")
|
48 |
-
@SwaggerResponse(
|
49 |
-
@SwaggerSummary("Get
|
|
|
50 |
get = async (req: Request, res: Response): Promise<Response> => {
|
51 |
-
const data = await this.exercisesService.findOneOrFail(
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
return JsonResponse.success(
|
56 |
{
|
57 |
-
data: serialize(data,
|
58 |
},
|
59 |
res
|
60 |
);
|
61 |
};
|
62 |
|
63 |
@SwaggerGet()
|
64 |
-
@SwaggerResponse([
|
65 |
-
@SwaggerSummary("Search
|
|
|
66 |
search = async (req: Request, res: Response): Promise<Response> => {
|
67 |
const paginationQuery = parsePaginationQuery(req.query);
|
68 |
let query = {};
|
@@ -101,12 +121,19 @@ export class ExerciseController extends BaseController {
|
|
101 |
|
102 |
const { docs, paginationData } = await this.exercisesService.search(
|
103 |
query,
|
104 |
-
paginationQuery
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
);
|
106 |
|
107 |
return JsonResponse.success(
|
108 |
{
|
109 |
-
data: serialize(docs,
|
110 |
meta: paginationData,
|
111 |
},
|
112 |
res
|
|
|
7 |
import { BaseController } from "@lib/controllers/controller.base";
|
8 |
import { Controller } from "@lib/decorators/controller.decorator";
|
9 |
import { serialize } from "@helpers/serialize";
|
10 |
+
import { ExercisePopulateSerialization } from "@common/serializers/exercisePopulate.serialization";
|
11 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
12 |
import { UsersGuardMiddleware } from "modules/users/common/guards/users.guard";
|
13 |
import { SwaggerGet } from "@lib/decorators/swagger-routes.decorator";
|
14 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
15 |
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
16 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
17 |
|
18 |
@Controller("/user/exercises")
|
19 |
@ControllerMiddleware(UsersGuardMiddleware())
|
20 |
+
export class UsersExerciseController extends BaseController {
|
21 |
private exercisesService = new ExerciseService();
|
22 |
|
23 |
setRoutes(): void {
|
|
|
27 |
}
|
28 |
|
29 |
@SwaggerGet()
|
30 |
+
@SwaggerResponse([ExercisePopulateSerialization])
|
31 |
+
@SwaggerSummary("List exercises")
|
32 |
+
@SwaggerDescription("List all exercises")
|
33 |
list = async (req: Request, res: Response): Promise<Response> => {
|
34 |
const paginationQuery = parsePaginationQuery(req.query);
|
35 |
const { docs, paginationData } = await this.exercisesService.list(
|
36 |
{},
|
37 |
+
paginationQuery,
|
38 |
+
{
|
39 |
+
populateArray: [
|
40 |
+
{ path: "targetMuscles.primary" },
|
41 |
+
{ path: "targetMuscles.primary" },
|
42 |
+
{ path: "equipments" }
|
43 |
+
]
|
44 |
+
}
|
45 |
);
|
46 |
|
47 |
return JsonResponse.success(
|
48 |
{
|
49 |
+
data: serialize(docs, ExercisePopulateSerialization),
|
50 |
meta: paginationData,
|
51 |
},
|
52 |
res
|
|
|
54 |
};
|
55 |
|
56 |
@SwaggerGet("/:id")
|
57 |
+
@SwaggerResponse(ExercisePopulateSerialization)
|
58 |
+
@SwaggerSummary("Get exercise")
|
59 |
+
@SwaggerDescription("Get a single exercise")
|
60 |
get = async (req: Request, res: Response): Promise<Response> => {
|
61 |
+
const data = await this.exercisesService.findOneOrFail(
|
62 |
+
{
|
63 |
+
_id: req.params.id,
|
64 |
+
},
|
65 |
+
{
|
66 |
+
populateArray: [
|
67 |
+
{ path: "targetMuscles.primary" },
|
68 |
+
{ path: "targetMuscles.primary" },
|
69 |
+
{ path: "equipments" }
|
70 |
+
]
|
71 |
+
}
|
72 |
+
);
|
73 |
|
74 |
return JsonResponse.success(
|
75 |
{
|
76 |
+
data: serialize(data, ExercisePopulateSerialization),
|
77 |
},
|
78 |
res
|
79 |
);
|
80 |
};
|
81 |
|
82 |
@SwaggerGet()
|
83 |
+
@SwaggerResponse([ExercisePopulateSerialization])
|
84 |
+
@SwaggerSummary("Search")
|
85 |
+
@SwaggerDescription("Search for exercises")
|
86 |
search = async (req: Request, res: Response): Promise<Response> => {
|
87 |
const paginationQuery = parsePaginationQuery(req.query);
|
88 |
let query = {};
|
|
|
121 |
|
122 |
const { docs, paginationData } = await this.exercisesService.search(
|
123 |
query,
|
124 |
+
paginationQuery,
|
125 |
+
{
|
126 |
+
populateArray: [
|
127 |
+
{ path: "targetMuscles.primary" },
|
128 |
+
{ path: "targetMuscles.primary" },
|
129 |
+
{ path: "equipments" }
|
130 |
+
]
|
131 |
+
}
|
132 |
);
|
133 |
|
134 |
return JsonResponse.success(
|
135 |
{
|
136 |
+
data: serialize(docs, ExercisePopulateSerialization),
|
137 |
meta: paginationData,
|
138 |
},
|
139 |
res
|
src/modules/users/modules/ingredients/controller/ingredients.controller.ts
CHANGED
@@ -28,7 +28,7 @@ export class UsersIngredientsController extends BaseController {
|
|
28 |
@SwaggerGet()
|
29 |
@SwaggerResponse([IngredientSerialization])
|
30 |
@SwaggerSummary("list ingredients")
|
31 |
-
@SwaggerDescription("
|
32 |
list = async (req: Request, res: Response) => {
|
33 |
const paginationQuery = parsePaginationQuery(req.query);
|
34 |
const { docs, paginationData } = await this.ingredientsService.list(
|
|
|
28 |
@SwaggerGet()
|
29 |
@SwaggerResponse([IngredientSerialization])
|
30 |
@SwaggerSummary("list ingredients")
|
31 |
+
@SwaggerDescription("List all ingredients")
|
32 |
list = async (req: Request, res: Response) => {
|
33 |
const paginationQuery = parsePaginationQuery(req.query);
|
34 |
const { docs, paginationData } = await this.ingredientsService.list(
|
src/modules/users/modules/meal-plans/controller/{meals.controller.ts → meal-plans.controller.ts}
RENAMED
@@ -1,5 +1,5 @@
|
|
1 |
import { MealPlansService } from "../services/meal-plans.service";
|
2 |
-
import {
|
3 |
import { Request, Response } from "express";
|
4 |
import { JsonResponse } from "@lib/responses/json-response";
|
5 |
import { parsePaginationQuery } from "@helpers/pagination";
|
@@ -25,9 +25,9 @@ export class UsersMealPlansController extends BaseController {
|
|
25 |
}
|
26 |
|
27 |
@SwaggerGet()
|
28 |
-
@SwaggerResponse([
|
29 |
@SwaggerSummary("list meal plans")
|
30 |
-
@SwaggerDescription("
|
31 |
list = async (req: Request, res: Response) => {
|
32 |
const paginationQuery = parsePaginationQuery(req.query);
|
33 |
const { docs, paginationData } = await this.mealPlansService.list(
|
@@ -35,14 +35,14 @@ export class UsersMealPlansController extends BaseController {
|
|
35 |
paginationQuery,
|
36 |
{
|
37 |
populateArray: [
|
38 |
-
{ path: "days.meals"
|
39 |
],
|
40 |
}
|
41 |
);
|
42 |
|
43 |
return JsonResponse.success(
|
44 |
{
|
45 |
-
data: serialize(docs,
|
46 |
meta: paginationData,
|
47 |
},
|
48 |
res
|
|
|
1 |
import { MealPlansService } from "../services/meal-plans.service";
|
2 |
+
import { MealPlanPopulateSerialization } from "@common/serializers/meal-planPopulate.serialization";
|
3 |
import { Request, Response } from "express";
|
4 |
import { JsonResponse } from "@lib/responses/json-response";
|
5 |
import { parsePaginationQuery } from "@helpers/pagination";
|
|
|
25 |
}
|
26 |
|
27 |
@SwaggerGet()
|
28 |
+
@SwaggerResponse([MealPlanPopulateSerialization])
|
29 |
@SwaggerSummary("list meal plans")
|
30 |
+
@SwaggerDescription("List all meal plans")
|
31 |
list = async (req: Request, res: Response) => {
|
32 |
const paginationQuery = parsePaginationQuery(req.query);
|
33 |
const { docs, paginationData } = await this.mealPlansService.list(
|
|
|
35 |
paginationQuery,
|
36 |
{
|
37 |
populateArray: [
|
38 |
+
{ path: "days.meals" }
|
39 |
],
|
40 |
}
|
41 |
);
|
42 |
|
43 |
return JsonResponse.success(
|
44 |
{
|
45 |
+
data: serialize(docs, MealPlanPopulateSerialization),
|
46 |
meta: paginationData,
|
47 |
},
|
48 |
res
|
src/modules/users/modules/meals/controller/meals.controller.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import { MealsService } from "../services/meals.service";
|
2 |
-
import {
|
3 |
import { Request, Response } from "express";
|
4 |
import { JsonResponse } from "@lib/responses/json-response";
|
5 |
import { parsePaginationQuery } from "@helpers/pagination";
|
@@ -25,9 +25,9 @@ export class UsersMealsController extends BaseController {
|
|
25 |
}
|
26 |
|
27 |
@SwaggerGet()
|
28 |
-
@SwaggerResponse([
|
29 |
@SwaggerSummary("list meals")
|
30 |
-
@SwaggerDescription("
|
31 |
list = async (req: Request, res: Response) => {
|
32 |
const paginationQuery = parsePaginationQuery(req.query);
|
33 |
const { docs, paginationData } = await this.mealsService.list(
|
@@ -41,7 +41,7 @@ export class UsersMealsController extends BaseController {
|
|
41 |
|
42 |
return JsonResponse.success(
|
43 |
{
|
44 |
-
data: serialize(docs,
|
45 |
meta: paginationData,
|
46 |
},
|
47 |
res
|
|
|
1 |
import { MealsService } from "../services/meals.service";
|
2 |
+
import { MealPopulateSerialization } from "@common/serializers/mealPopulate.serialization";
|
3 |
import { Request, Response } from "express";
|
4 |
import { JsonResponse } from "@lib/responses/json-response";
|
5 |
import { parsePaginationQuery } from "@helpers/pagination";
|
|
|
25 |
}
|
26 |
|
27 |
@SwaggerGet()
|
28 |
+
@SwaggerResponse([MealPopulateSerialization])
|
29 |
@SwaggerSummary("list meals")
|
30 |
+
@SwaggerDescription("List all meals")
|
31 |
list = async (req: Request, res: Response) => {
|
32 |
const paginationQuery = parsePaginationQuery(req.query);
|
33 |
const { docs, paginationData } = await this.mealsService.list(
|
|
|
41 |
|
42 |
return JsonResponse.success(
|
43 |
{
|
44 |
+
data: serialize(docs, MealPopulateSerialization),
|
45 |
meta: paginationData,
|
46 |
},
|
47 |
res
|
src/modules/users/modules/templates/controllers/templates.controller.ts
CHANGED
@@ -8,6 +8,7 @@ import { BaseController } from "@lib/controllers/controller.base";
|
|
8 |
import { Controller } from "@lib/decorators/controller.decorator";
|
9 |
import { serialize } from "@helpers/serialize";
|
10 |
import { TemplateSerialization } from "@common/serializers/template.serialization";
|
|
|
11 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
12 |
import { UsersGuardMiddleware } from "modules/users/common/guards/users.guard";
|
13 |
import {
|
@@ -18,7 +19,7 @@ import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
|
18 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
19 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
20 |
import { createTemplatesSchema } from "../validations/create-templates.validation";
|
21 |
-
import {
|
22 |
|
23 |
|
24 |
interface userRequest extends Request {
|
@@ -41,8 +42,9 @@ export class templateController extends BaseController {
|
|
41 |
}
|
42 |
|
43 |
@SwaggerGet()
|
44 |
-
@SwaggerResponse([
|
45 |
-
@SwaggerSummary("List
|
|
|
46 |
list = async (req: userRequest, res: Response): Promise<Response> => {
|
47 |
const paginationQuery = parsePaginationQuery(req.query);
|
48 |
const { docs, paginationData } = await this.templatesService.list(
|
@@ -50,14 +52,14 @@ export class templateController extends BaseController {
|
|
50 |
paginationQuery,
|
51 |
{
|
52 |
populateArray: [
|
53 |
-
{ path: "exercises"
|
54 |
],
|
55 |
}
|
56 |
);
|
57 |
|
58 |
return JsonResponse.success(
|
59 |
{
|
60 |
-
data: serialize(docs,
|
61 |
meta: paginationData,
|
62 |
},
|
63 |
res
|
@@ -65,8 +67,9 @@ export class templateController extends BaseController {
|
|
65 |
};
|
66 |
|
67 |
@SwaggerGet("/:id")
|
68 |
-
@SwaggerResponse(
|
69 |
-
@SwaggerSummary("Get
|
|
|
70 |
get = async (req: userRequest, res: Response): Promise<Response> => {
|
71 |
const data = await this.templatesService.findOneOrFail(
|
72 |
{
|
@@ -75,13 +78,13 @@ export class templateController extends BaseController {
|
|
75 |
},
|
76 |
{
|
77 |
populateArray: [
|
78 |
-
{ path: "exercises"
|
79 |
],
|
80 |
});
|
81 |
|
82 |
return JsonResponse.success(
|
83 |
{
|
84 |
-
data: serialize(data,
|
85 |
},
|
86 |
res
|
87 |
);
|
@@ -90,7 +93,8 @@ export class templateController extends BaseController {
|
|
90 |
@SwaggerPost()
|
91 |
@SwaggerResponse(TemplateSerialization)
|
92 |
@SwaggerRequest(createTemplatesSchema)
|
93 |
-
@SwaggerSummary("Create
|
|
|
94 |
create = async (req: userRequest, res: Response) => {
|
95 |
const data = await this.templatesService.create(req.body);
|
96 |
return JsonResponse.success(
|
|
|
8 |
import { Controller } from "@lib/decorators/controller.decorator";
|
9 |
import { serialize } from "@helpers/serialize";
|
10 |
import { TemplateSerialization } from "@common/serializers/template.serialization";
|
11 |
+
import { TemplatePopulateSerialization } from "@common/serializers/templatePopulate.serialization";
|
12 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
13 |
import { UsersGuardMiddleware } from "modules/users/common/guards/users.guard";
|
14 |
import {
|
|
|
19 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
20 |
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
21 |
import { createTemplatesSchema } from "../validations/create-templates.validation";
|
22 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
23 |
|
24 |
|
25 |
interface userRequest extends Request {
|
|
|
42 |
}
|
43 |
|
44 |
@SwaggerGet()
|
45 |
+
@SwaggerResponse([TemplatePopulateSerialization])
|
46 |
+
@SwaggerSummary("List my custom plans")
|
47 |
+
@SwaggerDescription("List all custom plans created by the user logged in")
|
48 |
list = async (req: userRequest, res: Response): Promise<Response> => {
|
49 |
const paginationQuery = parsePaginationQuery(req.query);
|
50 |
const { docs, paginationData } = await this.templatesService.list(
|
|
|
52 |
paginationQuery,
|
53 |
{
|
54 |
populateArray: [
|
55 |
+
{ path: "exercises" },
|
56 |
],
|
57 |
}
|
58 |
);
|
59 |
|
60 |
return JsonResponse.success(
|
61 |
{
|
62 |
+
data: serialize(docs, TemplatePopulateSerialization),
|
63 |
meta: paginationData,
|
64 |
},
|
65 |
res
|
|
|
67 |
};
|
68 |
|
69 |
@SwaggerGet("/:id")
|
70 |
+
@SwaggerResponse(TemplatePopulateSerialization)
|
71 |
+
@SwaggerSummary("Get custom plan")
|
72 |
+
@SwaggerDescription("Get a single custom plan created by the user logged in")
|
73 |
get = async (req: userRequest, res: Response): Promise<Response> => {
|
74 |
const data = await this.templatesService.findOneOrFail(
|
75 |
{
|
|
|
78 |
},
|
79 |
{
|
80 |
populateArray: [
|
81 |
+
{ path: "exercises" },
|
82 |
],
|
83 |
});
|
84 |
|
85 |
return JsonResponse.success(
|
86 |
{
|
87 |
+
data: serialize(data, TemplatePopulateSerialization),
|
88 |
},
|
89 |
res
|
90 |
);
|
|
|
93 |
@SwaggerPost()
|
94 |
@SwaggerResponse(TemplateSerialization)
|
95 |
@SwaggerRequest(createTemplatesSchema)
|
96 |
+
@SwaggerSummary("Create custom plan")
|
97 |
+
@SwaggerDescription("Create a new custom plan")
|
98 |
create = async (req: userRequest, res: Response) => {
|
99 |
const data = await this.templatesService.create(req.body);
|
100 |
return JsonResponse.success(
|
src/modules/users/modules/user-registered-meal-plans/controller/user-registered-meal-plans.controller.ts
CHANGED
@@ -1,13 +1,11 @@
|
|
1 |
import { UserRegisteredMealPlansService } from "../services/user-registered-meal-plans.service";
|
2 |
import { Request, Response } from "express";
|
3 |
import { JsonResponse } from "@lib/responses/json-response";
|
4 |
-
import { parsePaginationQuery } from "@helpers/pagination";
|
5 |
import { asyncHandler } from "@helpers/async-handler";
|
6 |
-
import { paramsValidator } from "@helpers/validation.helper";
|
7 |
import { BaseController } from "@lib/controllers/controller.base";
|
8 |
import { Controller } from "@lib/decorators/controller.decorator";
|
9 |
import { serialize } from "@helpers/serialize";
|
10 |
-
import {
|
11 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
12 |
import { UsersGuardMiddleware } from "modules/users/common/guards/users.guard";
|
13 |
import { SwaggerGet } from "@lib/decorators/swagger-routes.decorator";
|
@@ -28,22 +26,22 @@ export class UsersRegisteredMealPlansController extends BaseController {
|
|
28 |
}
|
29 |
|
30 |
@SwaggerGet()
|
31 |
-
@SwaggerResponse(
|
32 |
-
@SwaggerSummary("my meal plan")
|
33 |
-
@SwaggerDescription("Get the meal plan that the user is currently
|
34 |
get = async (req: userRequest, res: Response): Promise<Response> => {
|
35 |
const data = await this.userRegisteredMealPlansService.findOneOrFail(
|
36 |
{ user: req.jwtPayload._id, isActive: true },
|
37 |
{
|
38 |
populateArray: [
|
39 |
-
{ path: "
|
40 |
-
{ path: "days.meals"
|
41 |
],
|
42 |
});
|
43 |
|
44 |
return JsonResponse.success(
|
45 |
{
|
46 |
-
data: serialize(data,
|
47 |
},
|
48 |
res
|
49 |
);
|
|
|
1 |
import { UserRegisteredMealPlansService } from "../services/user-registered-meal-plans.service";
|
2 |
import { Request, Response } from "express";
|
3 |
import { JsonResponse } from "@lib/responses/json-response";
|
|
|
4 |
import { asyncHandler } from "@helpers/async-handler";
|
|
|
5 |
import { BaseController } from "@lib/controllers/controller.base";
|
6 |
import { Controller } from "@lib/decorators/controller.decorator";
|
7 |
import { serialize } from "@helpers/serialize";
|
8 |
+
import { UserRegisteredMealPlansPopulateSerialization } from "@common/serializers/user-registered-meal-planPopulate.serialization";
|
9 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
10 |
import { UsersGuardMiddleware } from "modules/users/common/guards/users.guard";
|
11 |
import { SwaggerGet } from "@lib/decorators/swagger-routes.decorator";
|
|
|
26 |
}
|
27 |
|
28 |
@SwaggerGet()
|
29 |
+
@SwaggerResponse(UserRegisteredMealPlansPopulateSerialization)
|
30 |
+
@SwaggerSummary("get my meal plan")
|
31 |
+
@SwaggerDescription("Get the meal plan that the user is currently using")
|
32 |
get = async (req: userRequest, res: Response): Promise<Response> => {
|
33 |
const data = await this.userRegisteredMealPlansService.findOneOrFail(
|
34 |
{ user: req.jwtPayload._id, isActive: true },
|
35 |
{
|
36 |
populateArray: [
|
37 |
+
{ path: "meal_plan" },
|
38 |
+
{ path: "days.meals"}
|
39 |
],
|
40 |
});
|
41 |
|
42 |
return JsonResponse.success(
|
43 |
{
|
44 |
+
data: serialize(data, UserRegisteredMealPlansPopulateSerialization),
|
45 |
},
|
46 |
res
|
47 |
);
|
src/modules/users/modules/user-registered-workouts/controllers/user-registered-workouts.controller.ts
CHANGED
@@ -8,10 +8,10 @@ import { BaseController } from "@lib/controllers/controller.base";
|
|
8 |
import { Controller } from "@lib/decorators/controller.decorator";
|
9 |
import { serialize } from "@helpers/serialize";
|
10 |
import { UserRegisteredWorkoutsSerialization } from "@common/serializers/user-registered-workout.serialization";
|
|
|
11 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
12 |
import { UsersGuardMiddleware } from "modules/users/common/guards/users.guard";
|
13 |
import { createUserRegisteredWorkoutsSchema } from "../validations/create-user-registered-workouts.validation";
|
14 |
-
import { updateUserRegisteredWorkoutsSchema } from "../validations/update-user-registered-workouts.validation";
|
15 |
import {
|
16 |
SwaggerGet,
|
17 |
SwaggerPost,
|
@@ -19,7 +19,8 @@ import {
|
|
19 |
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
20 |
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
21 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
22 |
-
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
|
|
|
23 |
|
24 |
interface userRequest extends Request {
|
25 |
jwtPayload?: any;
|
@@ -46,7 +47,8 @@ export class userRegisteredWorkoutsController extends BaseController {
|
|
46 |
}
|
47 |
|
48 |
@SwaggerGet()
|
49 |
-
@SwaggerResponse([
|
|
|
50 |
@SwaggerDescription("List all user registered workouts (workouts that the user had started)")
|
51 |
list = async (req: userRequest, res: Response) => {
|
52 |
const paginationQuery = parsePaginationQuery(req.query);
|
@@ -56,15 +58,15 @@ export class userRegisteredWorkoutsController extends BaseController {
|
|
56 |
paginationQuery,
|
57 |
{
|
58 |
populateArray: [
|
59 |
-
{ path: "workout"
|
60 |
-
{ path: "weeks.days.exercises"
|
61 |
],
|
62 |
}
|
63 |
);
|
64 |
|
65 |
return JsonResponse.success(
|
66 |
{
|
67 |
-
data: serialize(docs,
|
68 |
meta: paginationData,
|
69 |
},
|
70 |
res
|
@@ -72,43 +74,47 @@ export class userRegisteredWorkoutsController extends BaseController {
|
|
72 |
};
|
73 |
|
74 |
@SwaggerGet("/:id")
|
75 |
-
@SwaggerResponse(
|
|
|
76 |
@SwaggerDescription("Get a single workout from user registered workouts (workouts that the user had started)")
|
77 |
get = async (req: userRequest, res: Response) => {
|
78 |
const data = await this.userRegisteredWorkoutsService.findOneOrFail(
|
79 |
{ _id: req.params.id },
|
80 |
{
|
81 |
populateArray: [
|
82 |
-
{ path: "workout"
|
83 |
-
{ path: "weeks.days.exercises"
|
84 |
],
|
85 |
}
|
86 |
);
|
87 |
return JsonResponse.success(
|
88 |
{
|
89 |
-
data: serialize(data.toJSON(),
|
90 |
},
|
91 |
res
|
92 |
);
|
93 |
};
|
94 |
|
95 |
@SwaggerGet("/home/:userId")
|
96 |
-
@SwaggerResponse(
|
97 |
-
@SwaggerSummary("Get
|
|
|
98 |
getHomePage = async (req: userRequest, res: Response) => {
|
|
|
|
|
99 |
const data = await this.userRegisteredWorkoutsService.findOneOrFail(
|
100 |
{ user: req.params.userId },
|
101 |
{
|
102 |
populateArray: [
|
103 |
-
{ path: "workout"
|
104 |
-
{ path: "weeks.days.exercises"
|
105 |
-
{ path: "user"
|
106 |
],
|
107 |
}
|
108 |
);
|
109 |
return JsonResponse.success(
|
110 |
{
|
111 |
-
data: serialize(data.toJSON(),
|
112 |
},
|
113 |
res
|
114 |
);
|
@@ -117,7 +123,8 @@ export class userRegisteredWorkoutsController extends BaseController {
|
|
117 |
@SwaggerPost()
|
118 |
@SwaggerResponse(UserRegisteredWorkoutsSerialization)
|
119 |
@SwaggerRequest(createUserRegisteredWorkoutsSchema)
|
120 |
-
@SwaggerSummary("Create
|
|
|
121 |
create = async (req: userRequest, res: Response) => {
|
122 |
const data = await this.userRegisteredWorkoutsService.create(req.body);
|
123 |
return JsonResponse.success(
|
|
|
8 |
import { Controller } from "@lib/decorators/controller.decorator";
|
9 |
import { serialize } from "@helpers/serialize";
|
10 |
import { UserRegisteredWorkoutsSerialization } from "@common/serializers/user-registered-workout.serialization";
|
11 |
+
import { UserRegisteredMealPlansPopulateSerialization, UserRegisteredMealPlansPopulateUserSerialization } from "@common/serializers/user-registered-meal-planPopulate.serialization";
|
12 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
13 |
import { UsersGuardMiddleware } from "modules/users/common/guards/users.guard";
|
14 |
import { createUserRegisteredWorkoutsSchema } from "../validations/create-user-registered-workouts.validation";
|
|
|
15 |
import {
|
16 |
SwaggerGet,
|
17 |
SwaggerPost,
|
|
|
19 |
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
20 |
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
21 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
22 |
+
import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";4
|
23 |
+
|
24 |
|
25 |
interface userRequest extends Request {
|
26 |
jwtPayload?: any;
|
|
|
47 |
}
|
48 |
|
49 |
@SwaggerGet()
|
50 |
+
@SwaggerResponse([UserRegisteredMealPlansPopulateSerialization])
|
51 |
+
@SwaggerSummary("List my workouts")
|
52 |
@SwaggerDescription("List all user registered workouts (workouts that the user had started)")
|
53 |
list = async (req: userRequest, res: Response) => {
|
54 |
const paginationQuery = parsePaginationQuery(req.query);
|
|
|
58 |
paginationQuery,
|
59 |
{
|
60 |
populateArray: [
|
61 |
+
{ path: "workout" },
|
62 |
+
{ path: "weeks.days.exercises" },
|
63 |
],
|
64 |
}
|
65 |
);
|
66 |
|
67 |
return JsonResponse.success(
|
68 |
{
|
69 |
+
data: serialize(docs, UserRegisteredMealPlansPopulateSerialization),
|
70 |
meta: paginationData,
|
71 |
},
|
72 |
res
|
|
|
74 |
};
|
75 |
|
76 |
@SwaggerGet("/:id")
|
77 |
+
@SwaggerResponse(UserRegisteredMealPlansPopulateSerialization)
|
78 |
+
@SwaggerSummary("Get a workout")
|
79 |
@SwaggerDescription("Get a single workout from user registered workouts (workouts that the user had started)")
|
80 |
get = async (req: userRequest, res: Response) => {
|
81 |
const data = await this.userRegisteredWorkoutsService.findOneOrFail(
|
82 |
{ _id: req.params.id },
|
83 |
{
|
84 |
populateArray: [
|
85 |
+
{ path: "workout" },
|
86 |
+
{ path: "weeks.days.exercises" },
|
87 |
],
|
88 |
}
|
89 |
);
|
90 |
return JsonResponse.success(
|
91 |
{
|
92 |
+
data: serialize(data.toJSON(), UserRegisteredMealPlansPopulateSerialization),
|
93 |
},
|
94 |
res
|
95 |
);
|
96 |
};
|
97 |
|
98 |
@SwaggerGet("/home/:userId")
|
99 |
+
@SwaggerResponse(UserRegisteredMealPlansPopulateUserSerialization)
|
100 |
+
@SwaggerSummary("Get home page")
|
101 |
+
@SwaggerDescription("Get the home page for the user")
|
102 |
getHomePage = async (req: userRequest, res: Response) => {
|
103 |
+
console.log(req.params);
|
104 |
+
|
105 |
const data = await this.userRegisteredWorkoutsService.findOneOrFail(
|
106 |
{ user: req.params.userId },
|
107 |
{
|
108 |
populateArray: [
|
109 |
+
{ path: "workout" },
|
110 |
+
{ path: "weeks.days.exercises" },
|
111 |
+
{ path: "user" },
|
112 |
],
|
113 |
}
|
114 |
);
|
115 |
return JsonResponse.success(
|
116 |
{
|
117 |
+
data: serialize(data.toJSON(), UserRegisteredMealPlansPopulateUserSerialization),
|
118 |
},
|
119 |
res
|
120 |
);
|
|
|
123 |
@SwaggerPost()
|
124 |
@SwaggerResponse(UserRegisteredWorkoutsSerialization)
|
125 |
@SwaggerRequest(createUserRegisteredWorkoutsSchema)
|
126 |
+
@SwaggerSummary("Create workout")
|
127 |
+
@SwaggerDescription("Create a new workout for the user")
|
128 |
create = async (req: userRequest, res: Response) => {
|
129 |
const data = await this.userRegisteredWorkoutsService.create(req.body);
|
130 |
return JsonResponse.success(
|
src/modules/users/modules/users/controllers/users.controller.ts
CHANGED
@@ -12,6 +12,8 @@ import { ControllerMiddleware } from "@lib/decorators/controller-middleware.deco
|
|
12 |
import { UsersGuardMiddleware } from "modules/users/common/guards/users.guard";
|
13 |
import { SwaggerGet, SwaggerPut } from "@lib/decorators/swagger-routes.decorator";
|
14 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
|
|
|
|
15 |
|
16 |
@Controller("/users")
|
17 |
@ControllerMiddleware(UsersGuardMiddleware())
|
@@ -26,6 +28,8 @@ export class UsersController extends BaseController {
|
|
26 |
|
27 |
@SwaggerGet("/:id")
|
28 |
@SwaggerResponse(UserSerialization)
|
|
|
|
|
29 |
get = async (req: Request, res: Response): Promise<Response> => {
|
30 |
const data = await this.userService.findOneOrFail({
|
31 |
_id: req.params.id,
|
@@ -41,6 +45,8 @@ export class UsersController extends BaseController {
|
|
41 |
|
42 |
@SwaggerPut("/:id")
|
43 |
@SwaggerResponse(UserSerialization)
|
|
|
|
|
44 |
update = async (req: Request, res: Response): Promise<Response> => {
|
45 |
const data = await this.userService.updateOne(
|
46 |
{
|
|
|
12 |
import { UsersGuardMiddleware } from "modules/users/common/guards/users.guard";
|
13 |
import { SwaggerGet, SwaggerPut } from "@lib/decorators/swagger-routes.decorator";
|
14 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
15 |
+
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
16 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
17 |
|
18 |
@Controller("/users")
|
19 |
@ControllerMiddleware(UsersGuardMiddleware())
|
|
|
28 |
|
29 |
@SwaggerGet("/:id")
|
30 |
@SwaggerResponse(UserSerialization)
|
31 |
+
@SwaggerSummary("Get my account")
|
32 |
+
@SwaggerDescription("Get a my account details")
|
33 |
get = async (req: Request, res: Response): Promise<Response> => {
|
34 |
const data = await this.userService.findOneOrFail({
|
35 |
_id: req.params.id,
|
|
|
45 |
|
46 |
@SwaggerPut("/:id")
|
47 |
@SwaggerResponse(UserSerialization)
|
48 |
+
@SwaggerSummary("Update my account")
|
49 |
+
@SwaggerDescription("Update my account details")
|
50 |
update = async (req: Request, res: Response): Promise<Response> => {
|
51 |
const data = await this.userService.updateOne(
|
52 |
{
|
src/modules/users/modules/workouts/controllers/workouts.controller.ts
CHANGED
@@ -7,12 +7,13 @@ import { paramsValidator } from "@helpers/validation.helper";
|
|
7 |
import { BaseController } from "@lib/controllers/controller.base";
|
8 |
import { Controller } from "@lib/decorators/controller.decorator";
|
9 |
import { serialize } from "@helpers/serialize";
|
10 |
-
import {
|
11 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
12 |
import { UsersGuardMiddleware } from "modules/users/common/guards/users.guard";
|
13 |
import { SwaggerGet } from "@lib/decorators/swagger-routes.decorator";
|
14 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
15 |
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
|
|
16 |
|
17 |
|
18 |
@Controller("/user/workouts")
|
@@ -26,8 +27,9 @@ export class UsersWorkoutController extends BaseController {
|
|
26 |
}
|
27 |
|
28 |
@SwaggerGet()
|
29 |
-
@SwaggerResponse([
|
30 |
-
@SwaggerSummary("List
|
|
|
31 |
list = async (req: Request, res: Response): Promise<Response> => {
|
32 |
const paginationQuery = parsePaginationQuery(req.query);
|
33 |
const { docs, paginationData } = await this.workoutsService.list(
|
@@ -37,7 +39,7 @@ export class UsersWorkoutController extends BaseController {
|
|
37 |
|
38 |
return JsonResponse.success(
|
39 |
{
|
40 |
-
data: serialize(docs,
|
41 |
meta: paginationData,
|
42 |
},
|
43 |
res
|
@@ -45,8 +47,9 @@ export class UsersWorkoutController extends BaseController {
|
|
45 |
};
|
46 |
|
47 |
@SwaggerGet("/:id")
|
48 |
-
@SwaggerResponse(
|
49 |
-
@SwaggerSummary("Get
|
|
|
50 |
get = async (req: Request, res: Response): Promise<Response> => {
|
51 |
const data = await this.workoutsService.findOneOrFail(
|
52 |
{ _id: req.params.id },
|
@@ -58,7 +61,7 @@ export class UsersWorkoutController extends BaseController {
|
|
58 |
|
59 |
return JsonResponse.success(
|
60 |
{
|
61 |
-
data: serialize(data,
|
62 |
},
|
63 |
res
|
64 |
);
|
|
|
7 |
import { BaseController } from "@lib/controllers/controller.base";
|
8 |
import { Controller } from "@lib/decorators/controller.decorator";
|
9 |
import { serialize } from "@helpers/serialize";
|
10 |
+
import { WorkoutSerializationPopulate } from "@common/serializers/workoutPopulate.serialization";
|
11 |
import { ControllerMiddleware } from "@lib/decorators/controller-middleware.decorator";
|
12 |
import { UsersGuardMiddleware } from "modules/users/common/guards/users.guard";
|
13 |
import { SwaggerGet } from "@lib/decorators/swagger-routes.decorator";
|
14 |
import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
|
15 |
import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
|
16 |
+
import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
|
17 |
|
18 |
|
19 |
@Controller("/user/workouts")
|
|
|
27 |
}
|
28 |
|
29 |
@SwaggerGet()
|
30 |
+
@SwaggerResponse([WorkoutSerializationPopulate])
|
31 |
+
@SwaggerSummary("List workouts")
|
32 |
+
@SwaggerDescription("List all workouts in the system")
|
33 |
list = async (req: Request, res: Response): Promise<Response> => {
|
34 |
const paginationQuery = parsePaginationQuery(req.query);
|
35 |
const { docs, paginationData } = await this.workoutsService.list(
|
|
|
39 |
|
40 |
return JsonResponse.success(
|
41 |
{
|
42 |
+
data: serialize(docs, WorkoutSerializationPopulate),
|
43 |
meta: paginationData,
|
44 |
},
|
45 |
res
|
|
|
47 |
};
|
48 |
|
49 |
@SwaggerGet("/:id")
|
50 |
+
@SwaggerResponse(WorkoutSerializationPopulate)
|
51 |
+
@SwaggerSummary("Get workout")
|
52 |
+
@SwaggerDescription("Get a single workout")
|
53 |
get = async (req: Request, res: Response): Promise<Response> => {
|
54 |
const data = await this.workoutsService.findOneOrFail(
|
55 |
{ _id: req.params.id },
|
|
|
61 |
|
62 |
return JsonResponse.success(
|
63 |
{
|
64 |
+
data: serialize(data, WorkoutSerializationPopulate),
|
65 |
},
|
66 |
res
|
67 |
);
|