moahmedwafy commited on
Commit
163f5c1
·
1 Parent(s): 7e5807a

update: user register controller

Browse files
src/modules/users/modules/user-registered-workouts/controllers/user-registered-workouts.controller.ts CHANGED
@@ -30,7 +30,11 @@ export class userRegisteredWorkoutsController extends BaseController {
30
 
31
  setRoutes(): void {
32
  this.router.get("/:id", paramsValidator("id"), asyncHandler(this.get));
33
- this.router.get("/home/:userId", paramsValidator("userId"), asyncHandler(this.getHomePage));
 
 
 
 
34
  this.router.get("/", asyncHandler(this.list));
35
  this.router.post(
36
  "/",
@@ -43,16 +47,17 @@ export class userRegisteredWorkoutsController extends BaseController {
43
  @SwaggerResponse([UserRegisteredWorkoutsSerialization])
44
  list = async (req: userRequest, res: Response) => {
45
  const paginationQuery = parsePaginationQuery(req.query);
46
- const { docs, paginationData } = await this.userRegisteredWorkoutsService.list(
47
- { user: req.jwtPayload.id, is_active: true },
48
- paginationQuery,
49
- {
50
- populateArray: [
51
- { path: "workout", select: "-templateWeeks -created_by" },
52
- { path: "weeks.days.exercises", select: "name media reps sets" },
53
- ]
54
- }
55
- );
 
56
 
57
  return JsonResponse.success(
58
  {
@@ -72,7 +77,7 @@ export class userRegisteredWorkoutsController extends BaseController {
72
  populateArray: [
73
  { path: "workout", select: "-template_weeks -created_by" },
74
  { path: "weeks.days.exercises", select: "name media reps sets" },
75
- ]
76
  }
77
  );
78
  return JsonResponse.success(
@@ -83,6 +88,8 @@ export class userRegisteredWorkoutsController extends BaseController {
83
  );
84
  };
85
 
 
 
86
  getHomePage = async (req: userRequest, res: Response) => {
87
  const data = await this.userRegisteredWorkoutsService.findOneOrFail(
88
  { user: req.params.userId },
@@ -90,8 +97,8 @@ export class userRegisteredWorkoutsController extends BaseController {
90
  populateArray: [
91
  { path: "workout", select: "-template_weeks -created_by" },
92
  { path: "weeks.days.exercises", select: "name media reps sets" },
93
- { path: "user", select: "name preferences" }
94
- ]
95
  }
96
  );
97
  return JsonResponse.success(
 
30
 
31
  setRoutes(): void {
32
  this.router.get("/:id", paramsValidator("id"), asyncHandler(this.get));
33
+ this.router.get(
34
+ "/home/:userId",
35
+ paramsValidator("userId"),
36
+ asyncHandler(this.getHomePage)
37
+ );
38
  this.router.get("/", asyncHandler(this.list));
39
  this.router.post(
40
  "/",
 
47
  @SwaggerResponse([UserRegisteredWorkoutsSerialization])
48
  list = async (req: userRequest, res: Response) => {
49
  const paginationQuery = parsePaginationQuery(req.query);
50
+ const { docs, paginationData } =
51
+ await this.userRegisteredWorkoutsService.list(
52
+ { user: req.jwtPayload.id, is_active: true },
53
+ paginationQuery,
54
+ {
55
+ populateArray: [
56
+ { path: "workout", select: "-templateWeeks -created_by" },
57
+ { path: "weeks.days.exercises", select: "name media reps sets" },
58
+ ],
59
+ }
60
+ );
61
 
62
  return JsonResponse.success(
63
  {
 
77
  populateArray: [
78
  { path: "workout", select: "-template_weeks -created_by" },
79
  { path: "weeks.days.exercises", select: "name media reps sets" },
80
+ ],
81
  }
82
  );
83
  return JsonResponse.success(
 
88
  );
89
  };
90
 
91
+ @SwaggerGet("/home/:userId")
92
+ @SwaggerResponse(UserRegisteredWorkoutsSerialization)
93
  getHomePage = async (req: userRequest, res: Response) => {
94
  const data = await this.userRegisteredWorkoutsService.findOneOrFail(
95
  { user: req.params.userId },
 
97
  populateArray: [
98
  { path: "workout", select: "-template_weeks -created_by" },
99
  { path: "weeks.days.exercises", select: "name media reps sets" },
100
+ { path: "user", select: "name preferences" },
101
+ ],
102
  }
103
  );
104
  return JsonResponse.success(