Skip to content

Commit 6c13852

Browse files
author
Anmol Gangwar
committed
feat(endpoint): ⚡ Update Filtering at GetAllExercises endpoint
1 parent 2bde94e commit 6c13852

File tree

15 files changed

+736
-379
lines changed

15 files changed

+736
-379
lines changed

src/modules/bodyparts/controllers/bodyPart.controller.ts

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -49,87 +49,5 @@ export class BodyPartController implements Routes {
4949
return ctx.json({ success: true, data: response })
5050
}
5151
)
52-
// this.controller.openapi(
53-
// createRoute({
54-
// method: 'get',
55-
// path: '/bodyparts/{bodyPartName}/exercises',
56-
// tags: ['BodyParts'],
57-
// summary: 'Retrive exercises by bodyPart',
58-
// description: 'Retrive list of all bodyparts.',
59-
// operationId: 'getExercisesByBodyPart',
60-
// request: {
61-
// params: z.object({
62-
// bodyPartName: z.string().openapi({
63-
// description: 'bodyparts name',
64-
// type: 'string',
65-
// example: 'waist',
66-
// default: 'waist'
67-
// })
68-
// }),
69-
// query: z.object({
70-
// offset: z.coerce.number().nonnegative().optional().openapi({
71-
// title: 'Offset',
72-
// description:
73-
// 'The number of exercises to skip from the start of the list. Useful for pagination to fetch subsequent pages of results.',
74-
// type: 'number',
75-
// example: 10,
76-
// default: 0
77-
// }),
78-
// limit: z.coerce.number().positive().max(100).optional().openapi({
79-
// title: 'Limit',
80-
// description:
81-
// 'The maximum number of exercises to return in the response. Limits the number of results for pagination purposes.',
82-
// maximum: 100,
83-
// minimum: 1,
84-
// type: 'number',
85-
// example: 10,
86-
// default: 10
87-
// })
88-
// })
89-
// },
90-
// responses: {
91-
// 200: {
92-
// description: 'Successful response with list of all exercises.',
93-
// content: {
94-
// 'application/json': {
95-
// schema: z.object({
96-
// success: z.boolean().openapi({
97-
// description: 'Indicates whether the request was successful',
98-
// type: 'boolean',
99-
// example: true
100-
// }),
101-
// data: z.array(ExerciseModel).openapi({
102-
// description: 'Array of Exercises.'
103-
// })
104-
// })
105-
// }
106-
// }
107-
// },
108-
// 500: {
109-
// description: 'Internal server error'
110-
// }
111-
// }
112-
// }),
113-
// async (ctx) => {
114-
// const { offset, limit = 10 } = ctx.req.valid('query')
115-
// const search = ctx.req.param('bodyPartName')
116-
// const { origin, pathname } = new URL(ctx.req.url)
117-
// const response = await this.bodyPartService.getExercisesByBodyPart({ offset, limit, search })
118-
// return ctx.json({
119-
// success: true,
120-
// data: {
121-
// previousPage:
122-
// response.currentPage > 1
123-
// ? `${origin}${pathname}?offset=${(response.currentPage - 1) * limit}&limit=${limit}`
124-
// : null,
125-
// nextPage:
126-
// response.currentPage < response.totalPages
127-
// ? `${origin}${pathname}?offset=${response.currentPage * limit}&limit=${limit}`
128-
// : null,
129-
// ...response
130-
// }
131-
// })
132-
// }
133-
// )
13452
}
13553
}

src/modules/bodyparts/services/body-part.service.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,4 @@ export class BodyPartService {
1313
getBodyParts = () => {
1414
return this.getBodyPartsUseCase.execute()
1515
}
16-
17-
// getExercisesByBodyPart = (params: GetExerciseSerivceArgs) => {
18-
// const query: GetExercisesArgs = {
19-
// offset: params.offset,
20-
// limit: params.limit,
21-
// query: {
22-
// bodyParts: [...params.search]
23-
// }
24-
// }
25-
26-
// return this.getExercisesUseCase.execute(query)
27-
// }
2816
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { BodyPart } from 'src/data/types'
1+
import { BodyPart } from "../../../data/types";
22

33
export type FetchAllBodyPartRes = BodyPart[]

src/modules/bodyparts/use-cases/get-bodypart.usecase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { IUseCase } from '#common/types/use-case.type.js'
2-
import { FileLoader } from 'src/data/load'
2+
import { FileLoader } from "../../../data/load";
33
import { FetchAllBodyPartRes } from '../types'
44

55
export class GetBodyPartsUseCase implements IUseCase<void, FetchAllBodyPartRes> {

src/modules/equipments/controllers/equipment.controller.ts

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -50,87 +50,5 @@ export class EquipmentController implements Routes {
5050
return ctx.json({ success: true, data: response })
5151
}
5252
)
53-
// this.controller.openapi(
54-
// createRoute({
55-
// method: 'get',
56-
// path: '/equipments/{equipmentName}/exercises',
57-
// tags: ['Equipments'],
58-
// summary: 'Retrive exercises by equipments',
59-
// description: 'Retrive list of all equipments.',
60-
// operationId: 'getExercisesByEquipment',
61-
// request: {
62-
// params: z.object({
63-
// equipmentName: z.string().openapi({
64-
// description: 'equipments name',
65-
// type: 'string',
66-
// example: 'body weight',
67-
// default: 'body weight'
68-
// })
69-
// }),
70-
// query: z.object({
71-
// offset: z.coerce.number().nonnegative().optional().openapi({
72-
// title: 'Offset',
73-
// description:
74-
// 'The number of exercises to skip from the start of the list. Useful for pagination to fetch subsequent pages of results.',
75-
// type: 'number',
76-
// example: 10,
77-
// default: 0
78-
// }),
79-
// limit: z.coerce.number().positive().max(100).optional().openapi({
80-
// title: 'Limit',
81-
// description:
82-
// 'The maximum number of exercises to return in the response. Limits the number of results for pagination purposes.',
83-
// maximum: 100,
84-
// minimum: 1,
85-
// type: 'number',
86-
// example: 10,
87-
// default: 10
88-
// })
89-
// })
90-
// },
91-
// responses: {
92-
// 200: {
93-
// description: 'Successful response with list of all exercises.',
94-
// content: {
95-
// 'application/json': {
96-
// schema: z.object({
97-
// success: z.boolean().openapi({
98-
// description: 'Indicates whether the request was successful',
99-
// type: 'boolean',
100-
// example: true
101-
// }),
102-
// data: z.array(ExerciseModel).openapi({
103-
// description: 'Array of Exercises.'
104-
// })
105-
// })
106-
// }
107-
// }
108-
// },
109-
// 500: {
110-
// description: 'Internal server error'
111-
// }
112-
// }
113-
// }),
114-
// async (ctx) => {
115-
// const { offset, limit = 10 } = ctx.req.valid('query')
116-
// const search = ctx.req.param('equipmentName')
117-
// const { origin, pathname } = new URL(ctx.req.url)
118-
// const response = await this.equipmentService.getExercisesByEquipment({ offset, limit, search })
119-
// return ctx.json({
120-
// success: true,
121-
// data: {
122-
// previousPage:
123-
// response.currentPage > 1
124-
// ? `${origin}${pathname}?offset=${(response.currentPage - 1) * limit}&limit=${limit}`
125-
// : null,
126-
// nextPage:
127-
// response.currentPage < response.totalPages
128-
// ? `${origin}${pathname}?offset=${response.currentPage * limit}&limit=${limit}`
129-
// : null,
130-
// ...response
131-
// }
132-
// })
133-
// }
134-
// )
13553
}
13654
}

src/modules/equipments/services/equipment.service.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,4 @@ export class EquipmentService {
1414
getEquipments = () => {
1515
return this.getEquipmentUseCase.execute()
1616
}
17-
// getExercisesByEquipment = (params: GetExerciseSerivceArgs) => {
18-
// const query: GetExercisesArgs = {
19-
// offset: params.offset,
20-
// limit: params.limit,
21-
// query: {
22-
// equipments: {
23-
// $all: [params.search]
24-
// }
25-
// }
26-
// }
27-
28-
// return this.getExercisesUseCase.execute(query)
29-
// }
3017
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { Equipment } from 'src/data/types'
1+
import { Equipment } from '../../../data/types'
22

33
export type FetchAllEquipmentRes = Equipment[]

src/modules/equipments/use-cases/get-equipment.usecase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { IUseCase } from '#common/types/use-case.type.js'
2-
import { FileLoader } from 'src/data/load'
2+
import { FileLoader } from "../../../data/load";
33
import { FetchAllEquipmentRes } from '../types'
44

55
export class GetEquipmentsUseCase implements IUseCase<void, FetchAllEquipmentRes> {

0 commit comments

Comments
 (0)