moahmedwafy commited on
Commit
809bc07
·
1 Parent(s): d836ad1

update(console): no populate

Browse files
src/modules/console/modules/exercises/controllers/exercises.controller.ts CHANGED
@@ -8,7 +8,6 @@ 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 { 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";
@@ -47,7 +46,7 @@ export class ExercisesController extends BaseController {
47
  }
48
 
49
  @SwaggerGet()
50
- @SwaggerResponse([ExercisePopulateSerialization])
51
  @SwaggerSummary("List exercises")
52
  @SwaggerDescription("List all exercises in the system")
53
  @SwaggerQuery({
@@ -59,13 +58,6 @@ export class ExercisesController extends BaseController {
59
  const { docs, paginationData } = await this.exercisesService.list(
60
  {},
61
  paginationQuery,
62
- {
63
- populateArray: [
64
- { path: "targetMuscles.primary" },
65
- { path: "targetMuscles.secondary" },
66
- { path: "equipments" },
67
- ],
68
- }
69
  );
70
 
71
  return JsonResponse.success(
@@ -78,7 +70,7 @@ export class ExercisesController extends BaseController {
78
  };
79
 
80
  @SwaggerGet("/:id")
81
- @SwaggerResponse(ExercisePopulateSerialization)
82
  @SwaggerSummary("Get exercise")
83
  @SwaggerDescription("Get a single exercise by id")
84
  get = async (req: Request, res: Response) => {
@@ -86,13 +78,6 @@ export class ExercisesController extends BaseController {
86
  {
87
  _id: req.params.id,
88
  },
89
- {
90
- populateArray: [
91
- { path: "targetMuscles.primary" },
92
- { path: "targetMuscles.secondary" },
93
- { path: "equipments" },
94
- ],
95
- }
96
  );
97
  return JsonResponse.success(
98
  {
 
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";
 
46
  }
47
 
48
  @SwaggerGet()
49
+ @SwaggerResponse([ExerciseSerialization])
50
  @SwaggerSummary("List exercises")
51
  @SwaggerDescription("List all exercises in the system")
52
  @SwaggerQuery({
 
58
  const { docs, paginationData } = await this.exercisesService.list(
59
  {},
60
  paginationQuery,
 
 
 
 
 
 
 
61
  );
62
 
63
  return JsonResponse.success(
 
70
  };
71
 
72
  @SwaggerGet("/:id")
73
+ @SwaggerResponse(ExerciseSerialization)
74
  @SwaggerSummary("Get exercise")
75
  @SwaggerDescription("Get a single exercise by id")
76
  get = async (req: Request, res: Response) => {
 
78
  {
79
  _id: req.params.id,
80
  },
 
 
 
 
 
 
 
81
  );
82
  return JsonResponse.success(
83
  {
src/modules/console/modules/meal-plans/controller/meal-plans.controller.ts CHANGED
@@ -12,7 +12,6 @@ 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";
@@ -45,7 +44,7 @@ export class AdminsMealPlansController extends BaseController {
45
  }
46
 
47
  @SwaggerGet()
48
- @SwaggerResponse([MealPlanPopulateSerialization])
49
  @SwaggerSummary("List meal plans")
50
  @SwaggerDescription("List all meal plans in the system")
51
  @SwaggerQuery({
@@ -57,11 +56,6 @@ export class AdminsMealPlansController extends BaseController {
57
  const { docs, paginationData } = await this.mealPlansService.list(
58
  {},
59
  paginationQuery,
60
- {
61
- populateArray: [
62
- { path: "days.meals" }
63
- ],
64
- }
65
  );
66
 
67
  return JsonResponse.success(
@@ -74,7 +68,7 @@ export class AdminsMealPlansController extends BaseController {
74
  };
75
 
76
  @SwaggerGet('/:id')
77
- @SwaggerResponse(MealPlanPopulateSerialization)
78
  @SwaggerSummary('Get meal plan')
79
  @SwaggerDescription('Get meal plan by id')
80
  get = async (req: Request, res: Response) => {
@@ -82,11 +76,6 @@ export class AdminsMealPlansController extends BaseController {
82
  {
83
  _id: req.params.id,
84
  },
85
- {
86
- populateArray: [
87
- { path: "days.meals" }
88
- ],
89
- }
90
  );
91
  return JsonResponse.success(
92
  {
 
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";
 
44
  }
45
 
46
  @SwaggerGet()
47
+ @SwaggerResponse([MealPlanSerialization])
48
  @SwaggerSummary("List meal plans")
49
  @SwaggerDescription("List all meal plans in the system")
50
  @SwaggerQuery({
 
56
  const { docs, paginationData } = await this.mealPlansService.list(
57
  {},
58
  paginationQuery,
 
 
 
 
 
59
  );
60
 
61
  return JsonResponse.success(
 
68
  };
69
 
70
  @SwaggerGet('/:id')
71
+ @SwaggerResponse(MealPlanSerialization)
72
  @SwaggerSummary('Get meal plan')
73
  @SwaggerDescription('Get meal plan by id')
74
  get = async (req: Request, res: Response) => {
 
76
  {
77
  _id: req.params.id,
78
  },
 
 
 
 
 
79
  );
80
  return JsonResponse.success(
81
  {
src/modules/console/modules/meals/controller/meals.controller.ts CHANGED
@@ -12,7 +12,6 @@ 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 { 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";
@@ -45,7 +44,7 @@ export class AdminsMealsController extends BaseController {
45
  }
46
 
47
  @SwaggerGet()
48
- @SwaggerResponse([MealPopulateSerialization])
49
  @SwaggerSummary("List meals")
50
  @SwaggerDescription("List all meals in the system")
51
  @SwaggerQuery({
@@ -57,16 +56,11 @@ export class AdminsMealsController extends BaseController {
57
  const { docs, paginationData } = await this.mealsService.list(
58
  {},
59
  paginationQuery,
60
- {
61
- populateArray: [
62
- { path: "ingredients" }
63
- ],
64
- }
65
  );
66
 
67
  return JsonResponse.success(
68
  {
69
- data: serialize(docs, MealPopulateSerialization),
70
  meta: paginationData,
71
  },
72
  res
@@ -74,7 +68,7 @@ export class AdminsMealsController extends BaseController {
74
  };
75
 
76
  @SwaggerGet('/:id')
77
- @SwaggerResponse(MealPopulateSerialization)
78
  @SwaggerSummary('Get meal')
79
  @SwaggerDescription('Get meal by id')
80
  get = async (req: Request, res: Response) => {
@@ -82,15 +76,10 @@ export class AdminsMealsController extends BaseController {
82
  {
83
  _id: req.params.id,
84
  },
85
- {
86
- populateArray: [
87
- { path: "ingredients" }
88
- ],
89
- }
90
  );
91
  return JsonResponse.success(
92
  {
93
- data: serialize(data.toJSON(), MealPopulateSerialization),
94
  },
95
  res
96
  );
 
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";
 
44
  }
45
 
46
  @SwaggerGet()
47
+ @SwaggerResponse([MealSerialization])
48
  @SwaggerSummary("List meals")
49
  @SwaggerDescription("List all meals in the system")
50
  @SwaggerQuery({
 
56
  const { docs, paginationData } = await this.mealsService.list(
57
  {},
58
  paginationQuery,
 
 
 
 
 
59
  );
60
 
61
  return JsonResponse.success(
62
  {
63
+ data: serialize(docs, MealSerialization),
64
  meta: paginationData,
65
  },
66
  res
 
68
  };
69
 
70
  @SwaggerGet('/:id')
71
+ @SwaggerResponse(MealSerialization)
72
  @SwaggerSummary('Get meal')
73
  @SwaggerDescription('Get meal by id')
74
  get = async (req: Request, res: Response) => {
 
76
  {
77
  _id: req.params.id,
78
  },
 
 
 
 
 
79
  );
80
  return JsonResponse.success(
81
  {
82
+ data: serialize(data.toJSON(), MealSerialization),
83
  },
84
  res
85
  );
src/modules/console/modules/workouts/controllers/workouts.controller.ts CHANGED
@@ -10,7 +10,6 @@ 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 { 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 {
@@ -52,7 +51,7 @@ export class WorkoutController extends BaseController {
52
  }
53
 
54
  @SwaggerGet()
55
- @SwaggerResponse([WorkoutSerializationPopulate])
56
  @SwaggerSummary("List workouts")
57
  @SwaggerDescription("List all workouts in the system")
58
  @SwaggerQuery({
@@ -64,14 +63,11 @@ export class WorkoutController extends BaseController {
64
  const { docs, paginationData } = await this.workoutsService.list(
65
  {},
66
  paginationQuery,
67
- {
68
- populateArray: [{ path: "template_weeks.days.exercises" }],
69
- }
70
  );
71
 
72
  return JsonResponse.success(
73
  {
74
- data: serialize(docs, WorkoutSerializationPopulate),
75
  meta: paginationData,
76
  },
77
  res
@@ -79,7 +75,7 @@ export class WorkoutController extends BaseController {
79
  };
80
 
81
  @SwaggerGet("/:id")
82
- @SwaggerResponse(WorkoutSerializationPopulate)
83
  @SwaggerSummary("Get workout")
84
  @SwaggerDescription("Get workout by id")
85
  get = async (req: Request, res: Response) => {
@@ -87,13 +83,10 @@ export class WorkoutController extends BaseController {
87
  {
88
  _id: req.params.id,
89
  },
90
- {
91
- populateArray: [{ path: "template_weeks.days.exercises" }],
92
- }
93
  );
94
  return JsonResponse.success(
95
  {
96
- data: serialize(data.toJSON(), WorkoutSerializationPopulate),
97
  },
98
  res
99
  );
 
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 {
 
51
  }
52
 
53
  @SwaggerGet()
54
+ @SwaggerResponse([WorkoutSerialization])
55
  @SwaggerSummary("List workouts")
56
  @SwaggerDescription("List all workouts in the system")
57
  @SwaggerQuery({
 
63
  const { docs, paginationData } = await this.workoutsService.list(
64
  {},
65
  paginationQuery,
 
 
 
66
  );
67
 
68
  return JsonResponse.success(
69
  {
70
+ data: serialize(docs, WorkoutSerialization),
71
  meta: paginationData,
72
  },
73
  res
 
75
  };
76
 
77
  @SwaggerGet("/:id")
78
+ @SwaggerResponse(WorkoutSerialization)
79
  @SwaggerSummary("Get workout")
80
  @SwaggerDescription("Get workout by id")
81
  get = async (req: Request, res: Response) => {
 
83
  {
84
  _id: req.params.id,
85
  },
 
 
 
86
  );
87
  return JsonResponse.success(
88
  {
89
+ data: serialize(data.toJSON(), WorkoutSerialization),
90
  },
91
  res
92
  );