youssef Qatry commited on
Commit
6371208
·
unverified ·
2 Parent(s): bab17d1 9001303

Merge pull request #64 from Modarb-Ai-Trainer/swagger

Browse files
src/modules/users/modules/auth/controllers/auth.controller.ts CHANGED
@@ -15,6 +15,7 @@ import { UsersAuthService } from "../services/users-auth.service";
15
  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
 
19
  @Controller("/user/auth")
20
  export class UsersAuthController extends BaseController {
@@ -36,6 +37,7 @@ export class UsersAuthController extends BaseController {
36
  @SwaggerPost("/register")
37
  @SwaggerRequest(userRegisterSchema)
38
  @SwaggerResponse(UserSerialization)
 
39
  register = async (req: Request, res: Response) => {
40
  const user = await this.authService.register(req.body as IUserRegister);
41
 
@@ -50,6 +52,7 @@ export class UsersAuthController extends BaseController {
50
  @SwaggerPost("/login")
51
  @SwaggerRequest(loginValidationSchema)
52
  @SwaggerResponse(UserSerialization)
 
53
  login = async (req: Request, res: Response): Promise<Response> => {
54
  const { user, token } = await this.authService.login(req.body);
55
 
 
15
  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 {
 
37
  @SwaggerPost("/register")
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
 
 
52
  @SwaggerPost("/login")
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
 
src/modules/users/modules/exercises/controllers/exercises.controller.ts CHANGED
@@ -12,6 +12,7 @@ import { ControllerMiddleware } from "@lib/decorators/controller-middleware.deco
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
 
16
  @Controller("/user/exercises")
17
  @ControllerMiddleware(UsersGuardMiddleware())
@@ -26,6 +27,7 @@ export class ExerciseController extends BaseController {
26
 
27
  @SwaggerGet()
28
  @SwaggerResponse([ExerciseSerialization])
 
29
  list = async (req: Request, res: Response): Promise<Response> => {
30
  const paginationQuery = parsePaginationQuery(req.query);
31
  const { docs, paginationData } = await this.exercisesService.list(
@@ -44,6 +46,7 @@ export class ExerciseController extends BaseController {
44
 
45
  @SwaggerGet("/:id")
46
  @SwaggerResponse(ExerciseSerialization)
 
47
  get = async (req: Request, res: Response): Promise<Response> => {
48
  const data = await this.exercisesService.findOneOrFail({
49
  _id: req.params.id,
@@ -59,6 +62,7 @@ export class ExerciseController extends BaseController {
59
 
60
  @SwaggerGet()
61
  @SwaggerResponse([ExerciseSerialization])
 
62
  search = async (req: Request, res: Response): Promise<Response> => {
63
  const paginationQuery = parsePaginationQuery(req.query);
64
  let query = {};
 
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())
 
27
 
28
  @SwaggerGet()
29
  @SwaggerResponse([ExerciseSerialization])
30
+ @SwaggerSummary("List all exercises for the user")
31
  list = async (req: Request, res: Response): Promise<Response> => {
32
  const paginationQuery = parsePaginationQuery(req.query);
33
  const { docs, paginationData } = await this.exercisesService.list(
 
46
 
47
  @SwaggerGet("/:id")
48
  @SwaggerResponse(ExerciseSerialization)
49
+ @SwaggerSummary("Get a single exercise")
50
  get = async (req: Request, res: Response): Promise<Response> => {
51
  const data = await this.exercisesService.findOneOrFail({
52
  _id: req.params.id,
 
62
 
63
  @SwaggerGet()
64
  @SwaggerResponse([ExerciseSerialization])
65
+ @SwaggerSummary("Search for exercises")
66
  search = async (req: Request, res: Response): Promise<Response> => {
67
  const paginationQuery = parsePaginationQuery(req.query);
68
  let query = {};
src/modules/users/modules/templates/controllers/templates.controller.ts CHANGED
@@ -14,6 +14,7 @@ import {
14
  SwaggerGet,
15
  SwaggerPost,
16
  } 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 { createTemplatesSchema } from "../validations/create-templates.validation";
@@ -41,6 +42,7 @@ export class templateController extends BaseController {
41
 
42
  @SwaggerGet()
43
  @SwaggerResponse([TemplateSerialization])
 
44
  list = async (req: userRequest, res: Response): Promise<Response> => {
45
  const paginationQuery = parsePaginationQuery(req.query);
46
  const { docs, paginationData } = await this.templatesService.list(
@@ -64,6 +66,7 @@ export class templateController extends BaseController {
64
 
65
  @SwaggerGet("/:id")
66
  @SwaggerResponse(TemplateSerialization)
 
67
  get = async (req: userRequest, res: Response): Promise<Response> => {
68
  const data = await this.templatesService.findOneOrFail(
69
  {
@@ -87,6 +90,7 @@ export class templateController extends BaseController {
87
  @SwaggerPost()
88
  @SwaggerResponse(TemplateSerialization)
89
  @SwaggerRequest(createTemplatesSchema)
 
90
  create = async (req: userRequest, res: Response) => {
91
  const data = await this.templatesService.create(req.body);
92
  return JsonResponse.success(
 
14
  SwaggerGet,
15
  SwaggerPost,
16
  } from "@lib/decorators/swagger-routes.decorator";
17
+ 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";
 
42
 
43
  @SwaggerGet()
44
  @SwaggerResponse([TemplateSerialization])
45
+ @SwaggerSummary("List all templates for the user")
46
  list = async (req: userRequest, res: Response): Promise<Response> => {
47
  const paginationQuery = parsePaginationQuery(req.query);
48
  const { docs, paginationData } = await this.templatesService.list(
 
66
 
67
  @SwaggerGet("/:id")
68
  @SwaggerResponse(TemplateSerialization)
69
+ @SwaggerSummary("Get a single template")
70
  get = async (req: userRequest, res: Response): Promise<Response> => {
71
  const data = await this.templatesService.findOneOrFail(
72
  {
 
90
  @SwaggerPost()
91
  @SwaggerResponse(TemplateSerialization)
92
  @SwaggerRequest(createTemplatesSchema)
93
+ @SwaggerSummary("Create a new template plan")
94
  create = async (req: userRequest, res: Response) => {
95
  const data = await this.templatesService.create(req.body);
96
  return JsonResponse.success(
src/modules/users/modules/user-registered-workouts/controllers/user-registered-workouts.controller.ts CHANGED
@@ -16,6 +16,8 @@ import {
16
  SwaggerGet,
17
  SwaggerPost,
18
  } from "@lib/decorators/swagger-routes.decorator";
 
 
19
  import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
20
  import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
21
 
@@ -45,6 +47,7 @@ export class userRegisteredWorkoutsController extends BaseController {
45
 
46
  @SwaggerGet()
47
  @SwaggerResponse([UserRegisteredWorkoutsSerialization])
 
48
  list = async (req: userRequest, res: Response) => {
49
  const paginationQuery = parsePaginationQuery(req.query);
50
  const { docs, paginationData } =
@@ -70,6 +73,7 @@ export class userRegisteredWorkoutsController extends BaseController {
70
 
71
  @SwaggerGet("/:id")
72
  @SwaggerResponse(UserRegisteredWorkoutsSerialization)
 
73
  get = async (req: userRequest, res: Response) => {
74
  const data = await this.userRegisteredWorkoutsService.findOneOrFail(
75
  { _id: req.params.id },
@@ -90,6 +94,7 @@ export class userRegisteredWorkoutsController extends BaseController {
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 },
@@ -112,6 +117,7 @@ export class userRegisteredWorkoutsController extends BaseController {
112
  @SwaggerPost()
113
  @SwaggerResponse(UserRegisteredWorkoutsSerialization)
114
  @SwaggerRequest(createUserRegisteredWorkoutsSchema)
 
115
  create = async (req: userRequest, res: Response) => {
116
  const data = await this.userRegisteredWorkoutsService.create(req.body);
117
  return JsonResponse.success(
 
16
  SwaggerGet,
17
  SwaggerPost,
18
  } 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 { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
22
  import { SwaggerRequest } from "@lib/decorators/swagger-request.decorator";
23
 
 
47
 
48
  @SwaggerGet()
49
  @SwaggerResponse([UserRegisteredWorkoutsSerialization])
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);
53
  const { docs, paginationData } =
 
73
 
74
  @SwaggerGet("/:id")
75
  @SwaggerResponse(UserRegisteredWorkoutsSerialization)
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 },
 
94
 
95
  @SwaggerGet("/home/:userId")
96
  @SwaggerResponse(UserRegisteredWorkoutsSerialization)
97
+ @SwaggerSummary("Get the home page for the user")
98
  getHomePage = async (req: userRequest, res: Response) => {
99
  const data = await this.userRegisteredWorkoutsService.findOneOrFail(
100
  { user: req.params.userId },
 
117
  @SwaggerPost()
118
  @SwaggerResponse(UserRegisteredWorkoutsSerialization)
119
  @SwaggerRequest(createUserRegisteredWorkoutsSchema)
120
+ @SwaggerSummary("Create a workout for the user")
121
  create = async (req: userRequest, res: Response) => {
122
  const data = await this.userRegisteredWorkoutsService.create(req.body);
123
  return JsonResponse.success(
src/modules/users/modules/workouts/controllers/workouts.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 } from "@lib/decorators/swagger-routes.decorator";
14
  import { SwaggerResponse } from "@lib/decorators/swagger-response.decorator";
 
 
15
 
16
  @Controller("/user/workouts")
17
  @ControllerMiddleware(UsersGuardMiddleware())
@@ -25,6 +27,7 @@ export class UsersWorkoutController extends BaseController {
25
 
26
  @SwaggerGet()
27
  @SwaggerResponse([WorkoutSerialization])
 
28
  list = async (req: Request, res: Response): Promise<Response> => {
29
  const paginationQuery = parsePaginationQuery(req.query);
30
  const { docs, paginationData } = await this.workoutsService.list(
@@ -43,6 +46,7 @@ export class UsersWorkoutController extends BaseController {
43
 
44
  @SwaggerGet("/:id")
45
  @SwaggerResponse(WorkoutSerialization)
 
46
  get = async (req: Request, res: Response): Promise<Response> => {
47
  const data = await this.workoutsService.findOneOrFail(
48
  { _id: req.params.id },
 
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")
19
  @ControllerMiddleware(UsersGuardMiddleware())
 
27
 
28
  @SwaggerGet()
29
  @SwaggerResponse([WorkoutSerialization])
30
+ @SwaggerSummary("List all workouts for the user")
31
  list = async (req: Request, res: Response): Promise<Response> => {
32
  const paginationQuery = parsePaginationQuery(req.query);
33
  const { docs, paginationData } = await this.workoutsService.list(
 
46
 
47
  @SwaggerGet("/:id")
48
  @SwaggerResponse(WorkoutSerialization)
49
+ @SwaggerSummary("Get a single workout")
50
  get = async (req: Request, res: Response): Promise<Response> => {
51
  const data = await this.workoutsService.findOneOrFail(
52
  { _id: req.params.id },