Skip to content

Commit

Permalink
docs: add request body
Browse files Browse the repository at this point in the history
  • Loading branch information
Famozzy committed Nov 29, 2024
1 parent 445600f commit 1e53e2f
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 17 deletions.
20 changes: 16 additions & 4 deletions src/module/auth/auth.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,40 @@ authRouter.get(

authRouter.post(
"/register",
// #swagger.tags = ['auth']
/* #swagger.tags = ['auth']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/RegisterSchema" }
} */
validator(registerSchema),
authController.register,
);

authRouter.post(
"/login",
// #swagger.tags = ['auth']
/* #swagger.tags = ['auth']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/LoginSchema" }
} */
validator(loginSchema),
authController.login,
);

authRouter.post(
"/google",
// #swagger.tags = ['auth']
/* #swagger.tags = ['auth']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/OAuthSchema" }
} */
validator(oAuthSchema),
authController.googleAuth,
);

authRouter.post(
"/fcm-token",
// #swagger.tags = ['auth']
/* #swagger.tags = ['auth']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/FCMTokenSchema" }
} */
jwtAuthMiddleware,
validator(fcmTokenSchema),
authController.updateFCMToken,
Expand Down
25 changes: 21 additions & 4 deletions src/module/chat/chat.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ chatRouter.use(jwtAuthMiddleware);

chatRouter.post(
"/rooms",
// #swagger.tags = ['chat']
/* #swagger.tags = ['chat']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/CreateRoomSchema" }
} */
validator(createRoomSchema),
chatController.createRoom,
);
Expand All @@ -38,20 +41,34 @@ chatRouter.get(
// - For now i seperate it because of issue in zod that can't validate the request body properly
chatRouter.post(
"/rooms/:roomId/messages/text",
// #swagger.tags = ['chat']
/* #swagger.tags = ['chat']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/SendTextMessageSchema" }
} */
validator(sendTextMessageSchema),
chatController.sendMessage,
);
chatRouter.post(
"/rooms/:roomId/messages/image",
// #swagger.tags = ['chat']
/* #swagger.tags = ['chat']
#swagger.requestBody = {
required: true,
content: {
'image/jpg': {
schema: { type: 'string', format: 'binary' }
}
}
} */
validateChatImageUpload,
chatController.sendMessage,
);

chatRouter.post(
"/rooms/:roomId/typing",
// #swagger.tags = ['chat']
/* #swagger.tags = ['chat']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/SetIsTypingSchema" }
} */
validator(
z.object({
params: z.object({
Expand Down
20 changes: 17 additions & 3 deletions src/module/learner/learner.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,35 @@ learnerRouter.get(

learnerRouter.patch(
"/profile",
// #swagger.tags = ['learners']
/* #swagger.tags = ['learners']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/UpdateLearnerProfileSchema" }
} */
validator(updateProfileSchema),
learnerController.updateProfile,
);

learnerRouter.put(
"/profile/picture",
// #swagger.tags = ['learners']
/* #swagger.tags = ['learners']
#swagger.requestBody = {
required: true,
content: {
'image/jpg': {
schema: { type: 'string', format: 'binary' }
}
}
} */
validateProfilePictureUpload,
learnerController.updateProfilePicture,
);

learnerRouter.put(
"/password",
// #swagger.tags = ['learners']
/* #swagger.tags = ['learners']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/ChangePasswordSchema" }
} */
validator(changePasswordSchema),
learnerController.changePassword,
);
Expand Down
5 changes: 4 additions & 1 deletion src/module/order/order.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ orderRouter.get(

orderRouter.post(
"/",
// #swagger.tags = ['orders']
/* #swagger.tags = ['orders']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/CreateOrderSchema" }
} */
verifyLearner,
validator(createOrderSchema),
orderController.createOrder,
Expand Down
5 changes: 4 additions & 1 deletion src/module/review/review.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ reviewRouter.use(verifyLearner);

reviewRouter.post(
"/orders/:orderId",
// #swagger.tags = ['reviews']
/* #swagger.tags = ['reviews']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/CreateReviewSchema" }
} */
validator(createReviewSchema),
reviewController.createReview,
);
Expand Down
18 changes: 16 additions & 2 deletions src/module/tutor/tutor.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,34 @@ tutorRouter.get(
tutorRouter.patch(
"/profile",
// #swagger.tags = ['tutors']
/* #swagger.requestBody = {
schema: { $ref: "#/components/schemas/UpdateTutorProfileSchema" }
} */
validator(updateProfileSchema),
tutorController.updateProfile,
);

tutorRouter.put(
"/profile/picture",
// #swagger.tags = ['tutors']
/* #swagger.tags = ['tutors']
#swagger.requestBody = {
required: true,
content: {
'image/jpg': {
schema: { type: 'string', format: 'binary' }
}
}
} */
validateProfilePictureUpload,
tutorController.updateProfilePicture,
);

tutorRouter.put(
"/password",
// #swagger.tags = ['tutors']
/* #swagger.tags = ['tutors']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/ChangePasswordSchema" }
} */
validator(changePasswordSchema),
tutorController.changePassword,
);
Expand Down
10 changes: 8 additions & 2 deletions src/module/tutories/tutories.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@ tutoriesRouter.get(

tutoriesRouter.post(
"/",
// #swagger.tags = ['tutors/services']
/* #swagger.tags = ['tutors/services']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/CreateTutoriesSchema" }
} */
validator(createTutoriesSchema),
tutoriesController.createTutories,
);
tutoriesRouter.patch(
"/:tutoriesId",
// #swagger.tags = ['tutors/services']
/* #swagger.tags = ['tutors/services']
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/UpdateTutoriesSchema" }
} */
validator(updateTutoriesSchema),
tutoriesController.updateTutories,
);
Expand Down

0 comments on commit 1e53e2f

Please sign in to comment.