Hozifa Elgharbawy commited on
Commit
513e649
·
1 Parent(s): 9d0bbbd

add filters in list

Browse files
src/lib/services/crud.service.ts CHANGED
@@ -36,7 +36,7 @@ export const CrudService = <ModelDoc extends Document>(
36
  }
37
 
38
  async list(
39
- filter: FilterQuery<ModelDoc>,
40
  paginationOptions: {
41
  limit?: number;
42
  skip?: number;
@@ -45,7 +45,8 @@ export const CrudService = <ModelDoc extends Document>(
45
  skip: 1,
46
  },
47
  options?: {
48
- populateArray: any
 
49
  },
50
  ): Promise<{
51
  docs: ModelDoc[];
@@ -55,6 +56,7 @@ export const CrudService = <ModelDoc extends Document>(
55
  perPage: number;
56
  };
57
  }> {
 
58
  const queryInstruction = this.model
59
  .find(filter)
60
  .limit(paginationOptions.limit)
 
36
  }
37
 
38
  async list(
39
+ filter: FilterQuery<ModelDoc>,
40
  paginationOptions: {
41
  limit?: number;
42
  skip?: number;
 
45
  skip: 1,
46
  },
47
  options?: {
48
+ populateArray?: any,
49
+ filterOptions?: any
50
  },
51
  ): Promise<{
52
  docs: ModelDoc[];
 
56
  perPage: number;
57
  };
58
  }> {
59
+ if (options?.filterOptions) filter = { ...filter, ...options.filterOptions };
60
  const queryInstruction = this.model
61
  .find(filter)
62
  .limit(paginationOptions.limit)
src/modules/console/modules/admins/controllers/admins.controller.ts CHANGED
@@ -26,6 +26,7 @@ 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
 
30
  @Controller("/console/admins")
31
  @ControllerMiddleware(AdminGuardMiddleware({ roles: [Role.SUPER_ADMIN] }))
@@ -57,6 +58,10 @@ export class AdminsController extends BaseController {
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[]>>
 
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] }))
 
58
  @SwaggerResponse([AdminSerialization])
59
  @SwaggerSummary("List admins")
60
  @SwaggerDescription("List all admins in the system")
61
+ @SwaggerQuery({
62
+ limit: "number",
63
+ skip: "number",
64
+ })
65
  list = async (
66
  req: Request,
67
  res: Response<IJSONSuccessResponse<AdminSerialization[]>>
src/modules/console/modules/equipments/controllers/equipments.controller.ts CHANGED
@@ -22,6 +22,7 @@ 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 {
@@ -52,6 +53,10 @@ export class EquipmentsController extends BaseController {
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(
 
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
+ import { SwaggerQuery } from "@lib/decorators/swagger-query.decorator";
26
  @Controller("/console/equipments")
27
  @ControllerMiddleware(AdminGuardMiddleware({}))
28
  export class EquipmentsController extends BaseController {
 
53
  @SwaggerResponse([EquipmentSerialization])
54
  @SwaggerSummary("List equipments")
55
  @SwaggerDescription("List all equipments in the system")
56
+ @SwaggerQuery({
57
+ limit: "number",
58
+ skip: "number",
59
+ })
60
  list = async (req: Request, res: Response) => {
61
  const paginationQuery = parsePaginationQuery(req.query);
62
  const { docs, paginationData } = await this.equipmentsService.list(
src/modules/console/modules/exercises/controllers/exercises.controller.ts CHANGED
@@ -18,6 +18,7 @@ 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({}))
@@ -49,6 +50,10 @@ export class ExercisesController extends BaseController {
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(
 
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
+ import { SwaggerQuery } from "@lib/decorators/swagger-query.decorator";
22
 
23
  @Controller("/console/exercises")
24
  @ControllerMiddleware(AdminGuardMiddleware({}))
 
50
  @SwaggerResponse([ExercisePopulateSerialization])
51
  @SwaggerSummary("List exercises")
52
  @SwaggerDescription("List all exercises in the system")
53
+ @SwaggerQuery({
54
+ limit: "number",
55
+ skip: "number",
56
+ })
57
  list = async (req: Request, res: Response) => {
58
  const paginationQuery = parsePaginationQuery(req.query);
59
  const { docs, paginationData } = await this.exercisesService.list(
src/modules/console/modules/ingredients/controller/ingredients.controller.ts CHANGED
@@ -17,6 +17,7 @@ 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({}))
@@ -46,6 +47,10 @@ export class AdminsIngredientsController extends BaseController {
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(
 
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
+ import { SwaggerQuery } from "@lib/decorators/swagger-query.decorator";
21
 
22
  @Controller("/console/ingredients")
23
  @ControllerMiddleware(AdminGuardMiddleware({}))
 
47
  @SwaggerResponse([IngredientSerialization])
48
  @SwaggerSummary("List ingredients")
49
  @SwaggerDescription("List all ingredients in the system")
50
+ @SwaggerQuery({
51
+ limit: "number",
52
+ skip: "number",
53
+ })
54
  list = async (req: Request, res: Response) => {
55
  const paginationQuery = parsePaginationQuery(req.query);
56
  const { docs, paginationData } = await this.ingredientsService.list(
src/modules/console/modules/meal-plans/controller/meal-plans.controller.ts CHANGED
@@ -18,6 +18,7 @@ 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({}))
@@ -47,6 +48,10 @@ export class AdminsMealPlansController extends BaseController {
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(
 
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
+ import { SwaggerQuery } from "@lib/decorators/swagger-query.decorator";
22
 
23
  @Controller("/console/mealPlans")
24
  @ControllerMiddleware(AdminGuardMiddleware({}))
 
48
  @SwaggerResponse([MealPlanPopulateSerialization])
49
  @SwaggerSummary("List meal plans")
50
  @SwaggerDescription("List all meal plans in the system")
51
+ @SwaggerQuery({
52
+ limit: "number",
53
+ skip: "number",
54
+ })
55
  list = async (req: Request, res: Response) => {
56
  const paginationQuery = parsePaginationQuery(req.query);
57
  const { docs, paginationData } = await this.mealPlansService.list(
src/modules/console/modules/meals/controller/meals.controller.ts CHANGED
@@ -18,6 +18,7 @@ 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({}))
@@ -47,6 +48,10 @@ export class AdminsMealsController extends BaseController {
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(
 
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
+ import { SwaggerQuery } from "@lib/decorators/swagger-query.decorator";
22
 
23
  @Controller("/console/meals")
24
  @ControllerMiddleware(AdminGuardMiddleware({}))
 
48
  @SwaggerResponse([MealPopulateSerialization])
49
  @SwaggerSummary("List meals")
50
  @SwaggerDescription("List all meals in the system")
51
+ @SwaggerQuery({
52
+ limit: "number",
53
+ skip: "number",
54
+ })
55
  list = async (req: Request, res: Response) => {
56
  const paginationQuery = parsePaginationQuery(req.query);
57
  const { docs, paginationData } = await this.mealsService.list(
src/modules/console/modules/muscles/controllers/muscles.controller.ts CHANGED
@@ -17,6 +17,7 @@ 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({}))
@@ -46,6 +47,10 @@ export class MusclesController extends BaseController {
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(
 
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
+ import { SwaggerQuery } from "@lib/decorators/swagger-query.decorator";
21
 
22
  @Controller("/console/muscles")
23
  @ControllerMiddleware(AdminGuardMiddleware({}))
 
47
  @SwaggerResponse([MuscleSerialization])
48
  @SwaggerSummary("List muscles")
49
  @SwaggerDescription("List all muscles in the system")
50
+ @SwaggerQuery({
51
+ limit: "number",
52
+ skip: "number",
53
+ })
54
  list = async (req: Request, res: Response) => {
55
  const paginationQuery = parsePaginationQuery(req.query);
56
  const { docs, paginationData } = await this.musclesService.list(
src/modules/console/modules/workouts/controllers/workouts.controller.ts CHANGED
@@ -23,6 +23,7 @@ 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({}))
@@ -54,6 +55,10 @@ export class WorkoutController extends BaseController {
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(
 
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
+ import { SwaggerQuery } from "@lib/decorators/swagger-query.decorator";
27
 
28
  @Controller("/console/workouts")
29
  @ControllerMiddleware(AdminGuardMiddleware({}))
 
55
  @SwaggerResponse([WorkoutSerializationPopulate])
56
  @SwaggerSummary("List workouts")
57
  @SwaggerDescription("List all workouts in the system")
58
+ @SwaggerQuery({
59
+ limit: "number",
60
+ skip: "number",
61
+ })
62
  list = async (req: Request, res: Response) => {
63
  const paginationQuery = parsePaginationQuery(req.query);
64
  const { docs, paginationData } = await this.workoutsService.list(
src/modules/users/modules/exercises/controllers/exercises.controller.ts CHANGED
@@ -33,6 +33,7 @@ export class UsersExerciseController extends BaseController {
33
  @SwaggerDescription("List all exercises")
34
  @SwaggerQuery({
35
  limit: "number",
 
36
  })
37
  list = async (req: Request, res: Response): Promise<Response> => {
38
  const paginationQuery = parsePaginationQuery(req.query);
@@ -91,7 +92,6 @@ export class UsersExerciseController extends BaseController {
91
  const paginationQuery = parsePaginationQuery(req.query);
92
  let query = {};
93
  let searchTerm = req.query.searchTerm;
94
-
95
  let isNum = !isNaN(parseInt(String(searchTerm)));
96
 
97
  if (isNum) {
@@ -106,6 +106,8 @@ export class UsersExerciseController extends BaseController {
106
  }
107
 
108
  else {
 
 
109
  if (req.query.filter === "category") {
110
  query = { category: { $regex: searchTerm, $options: "i" } };
111
  }
 
33
  @SwaggerDescription("List all exercises")
34
  @SwaggerQuery({
35
  limit: "number",
36
+ skip: "number",
37
  })
38
  list = async (req: Request, res: Response): Promise<Response> => {
39
  const paginationQuery = parsePaginationQuery(req.query);
 
92
  const paginationQuery = parsePaginationQuery(req.query);
93
  let query = {};
94
  let searchTerm = req.query.searchTerm;
 
95
  let isNum = !isNaN(parseInt(String(searchTerm)));
96
 
97
  if (isNum) {
 
106
  }
107
 
108
  else {
109
+ console.log(req.query);
110
+
111
  if (req.query.filter === "category") {
112
  query = { category: { $regex: searchTerm, $options: "i" } };
113
  }
src/modules/users/modules/ingredients/controller/ingredients.controller.ts CHANGED
@@ -14,6 +14,7 @@ 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/ingredients")
@@ -29,6 +30,10 @@ export class UsersIngredientsController extends BaseController {
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(
 
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
+ import { SwaggerQuery } from "@lib/decorators/swagger-query.decorator";
18
 
19
 
20
  @Controller("/user/ingredients")
 
30
  @SwaggerResponse([IngredientSerialization])
31
  @SwaggerSummary("list ingredients")
32
  @SwaggerDescription("List all ingredients")
33
+ @SwaggerQuery({
34
+ limit: "number",
35
+ skip: "number",
36
+ })
37
  list = async (req: Request, res: Response) => {
38
  const paginationQuery = parsePaginationQuery(req.query);
39
  const { docs, paginationData } = await this.ingredientsService.list(
src/modules/users/modules/meal-plans/controller/meal-plans.controller.ts CHANGED
@@ -13,6 +13,7 @@ import { SwaggerGet } from "@lib/decorators/swagger-routes.decorator";
13
  import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
14
  import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
15
  import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
 
16
 
17
 
18
  @Controller("/user/mealPlans")
@@ -28,6 +29,10 @@ export class UsersMealPlansController extends BaseController {
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(
 
13
  import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
14
  import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
15
  import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
16
+ import { SwaggerQuery } from "@lib/decorators/swagger-query.decorator";
17
 
18
 
19
  @Controller("/user/mealPlans")
 
29
  @SwaggerResponse([MealPlanPopulateSerialization])
30
  @SwaggerSummary("list meal plans")
31
  @SwaggerDescription("List all meal plans")
32
+ @SwaggerQuery({
33
+ limit: "number",
34
+ skip: "number",
35
+ })
36
  list = async (req: Request, res: Response) => {
37
  const paginationQuery = parsePaginationQuery(req.query);
38
  const { docs, paginationData } = await this.mealPlansService.list(
src/modules/users/modules/meals/controller/meals.controller.ts CHANGED
@@ -13,6 +13,7 @@ import { SwaggerGet } from "@lib/decorators/swagger-routes.decorator";
13
  import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
14
  import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
15
  import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
 
16
 
17
 
18
  @Controller("/user/meals")
@@ -28,6 +29,10 @@ export class UsersMealsController extends BaseController {
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(
 
13
  import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
14
  import { SwaggerSummary } from "@lib/decorators/swagger-summary.decorator";
15
  import { SwaggerDescription } from "@lib/decorators/swagger-description.decorator";
16
+ import { SwaggerQuery } from "@lib/decorators/swagger-query.decorator";
17
 
18
 
19
  @Controller("/user/meals")
 
29
  @SwaggerResponse([MealPopulateSerialization])
30
  @SwaggerSummary("list meals")
31
  @SwaggerDescription("List all meals")
32
+ @SwaggerQuery({
33
+ limit: "number",
34
+ skip: "number",
35
+ })
36
  list = async (req: Request, res: Response) => {
37
  const paginationQuery = parsePaginationQuery(req.query);
38
  const { docs, paginationData } = await this.mealsService.list(
src/modules/users/modules/templates/controllers/templates.controller.ts CHANGED
@@ -20,6 +20,7 @@ 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 {
@@ -45,6 +46,10 @@ export class templateController extends BaseController {
45
  @SwaggerResponse([TemplatePopulateSerialization])
46
  @SwaggerSummary("my trainer --> custom workout")
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(
 
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
+ import { SwaggerQuery } from "@lib/decorators/swagger-query.decorator";
24
 
25
 
26
  interface userRequest extends Request {
 
46
  @SwaggerResponse([TemplatePopulateSerialization])
47
  @SwaggerSummary("my trainer --> custom workout")
48
  @SwaggerDescription("List all custom plans created by the user logged in")
49
+ @SwaggerQuery({
50
+ limit: "number",
51
+ skip: "number",
52
+ })
53
  list = async (req: userRequest, res: Response): Promise<Response> => {
54
  const paginationQuery = parsePaginationQuery(req.query);
55
  const { docs, paginationData } = await this.templatesService.list(
src/modules/users/modules/workouts/controllers/workouts.controller.ts CHANGED
@@ -14,6 +14,7 @@ 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")
@@ -30,6 +31,10 @@ export class UsersWorkoutController extends BaseController {
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(
 
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
+ import { SwaggerQuery } from "@lib/decorators/swagger-query.decorator";
18
 
19
 
20
  @Controller("/user/workouts")
 
31
  @SwaggerResponse([WorkoutSerializationPopulate])
32
  @SwaggerSummary("List workouts")
33
  @SwaggerDescription("List all workouts in the system")
34
+ @SwaggerQuery({
35
+ limit: "number",
36
+ skip: "number",
37
+ })
38
  list = async (req: Request, res: Response): Promise<Response> => {
39
  const paginationQuery = parsePaginationQuery(req.query);
40
  const { docs, paginationData } = await this.workoutsService.list(