Skip to content

Commit

Permalink
docs: add description to all route
Browse files Browse the repository at this point in the history
  • Loading branch information
Veirt committed Dec 11, 2024
1 parent 108cdd7 commit 85f56b4
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/module/auth/auth.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ const authRouter = Router();
authRouter.get(
"/me",
// #swagger.tags = ['auth']
// #swagger.description = 'Get currently logged in user'
jwtAuthMiddleware,
authController.getUser,
);

authRouter.post(
"/register",
/* #swagger.tags = ['auth']
#swagger.description = 'Register a new user'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/RegisterSchema" }
} */
Expand All @@ -32,6 +34,7 @@ authRouter.post(
authRouter.post(
"/login",
/* #swagger.tags = ['auth']
#swagger.description = 'Login user'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/LoginSchema" }
} */
Expand All @@ -42,6 +45,7 @@ authRouter.post(
authRouter.post(
"/google",
/* #swagger.tags = ['auth']
#swagger.description = 'Login user with Google OAuth'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/OAuthSchema" }
} */
Expand All @@ -52,6 +56,7 @@ authRouter.post(
authRouter.post(
"/fcm-token",
/* #swagger.tags = ['auth']
#swagger.description = 'Add FCM token to user'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/FCMTokenSchema" }
} */
Expand All @@ -63,6 +68,7 @@ authRouter.post(
authRouter.delete(
"/fcm-token",
// #swagger.tags = ['auth']
// #swagger.description = 'Remove FCM token from user'
jwtAuthMiddleware,
validator(fcmTokenSchema),
authController.removeFCMToken,
Expand Down
1 change: 1 addition & 0 deletions src/module/category/category.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const categoryRouter = Router();
categoryRouter.get(
"/",
// #swagger.tags = ['categories']
// #swagger.description = 'Get all categories'
categoryController.getAllCategories,
);

Expand Down
6 changes: 6 additions & 0 deletions src/module/chat/chat.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ chatRouter.use(jwtAuthMiddleware);
chatRouter.post(
"/rooms",
/* #swagger.tags = ['chat']
#swagger.description = 'Create a new chat room'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/CreateRoomSchema" }
} */
Expand All @@ -28,11 +29,13 @@ chatRouter.post(
chatRouter.get(
"/rooms",
// #swagger.tags = ['chat']
// #swagger.description = 'Get all chat rooms'
chatController.getRooms,
);
chatRouter.get(
"/rooms/:roomId/messages",
// #swagger.tags = ['chat']
// #swagger.description = 'Get messages in a chat room'
validator(getRoomMessagesSchema),
chatController.getRoomMessages,
);
Expand All @@ -42,6 +45,7 @@ chatRouter.get(
chatRouter.post(
"/rooms/:roomId/messages/text",
/* #swagger.tags = ['chat']
#swagger.description = 'Send a text message'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/SendTextMessageSchema" }
} */
Expand All @@ -66,6 +70,7 @@ chatRouter.post(
chatRouter.post(
"/rooms/:roomId/typing",
/* #swagger.tags = ['chat']
#swagger.description = 'Update typing status'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/SetIsTypingSchema" }
} */
Expand All @@ -85,6 +90,7 @@ chatRouter.post(
chatRouter.get(
"/rooms/:roomId/presence",
// #swagger.tags = ['chat']
// #swagger.description = 'Get room presence'
validator(
z.object({
params: z.object({
Expand Down
6 changes: 6 additions & 0 deletions src/module/learner/learner.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ learnerRouter.use(verifyLearner);
learnerRouter.get(
"/profile",
// #swagger.tags = ['learners']
// #swagger.description = 'Get the profile data of the currently logged in learner'
learnerController.getProfile,
);

learnerRouter.patch(
"/profile",
/* #swagger.tags = ['learners']
#swagger.description = 'Update the profile data of the currently logged in learner'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/UpdateLearnerProfileSchema" }
} */
Expand All @@ -39,6 +41,7 @@ learnerRouter.patch(
learnerRouter.patch(
"/profile/learning-style",
/* #swagger.tags = ['learners']
#swagger.description = 'Update the learning style of the currently logged in learner'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/UpdateLearningStyleSchema" }
} */
Expand All @@ -49,6 +52,7 @@ learnerRouter.patch(
learnerRouter.patch(
"/profile/interests",
/* #swagger.tags = ['learners']
#swagger.description = 'Update the interests of the currently logged in learner'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/UpdateInterestsSchema" }
} */
Expand All @@ -59,6 +63,7 @@ learnerRouter.patch(
learnerRouter.put(
"/profile/picture",
/* #swagger.tags = ['learners']
#swagger.description = 'Update the profile picture of the currently logged in learner'
#swagger.requestBody = {
required: true,
content: {
Expand All @@ -74,6 +79,7 @@ learnerRouter.put(
learnerRouter.put(
"/password",
/* #swagger.tags = ['learners']
#swagger.description = 'Change the password of the currently logged in learner'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/ChangePasswordSchema" }
} */
Expand Down
3 changes: 3 additions & 0 deletions src/module/notification/notification.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@ notificationRouter.use(jwtAuthMiddleware);
notificationRouter.get(
"/",
// #swagger.tags = ['notifications']
// #swagger.description = 'Get all notifications for the logged in user'
validator(getNotificationsSchema),
getNotifications,
);

notificationRouter.post(
"/:notificationId/read",
// #swagger.tags = ['notifications']
// #swagger.description = 'Mark a notification as read'
validator(markAsReadSchema),
markAsRead,
);

notificationRouter.post(
"/read-all",
// #swagger.tags = ['notifications']
// #swagger.description = 'Mark all notifications as read'
markAllAsRead,
);

Expand Down
6 changes: 6 additions & 0 deletions src/module/order/order.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ orderRouter.use(jwtAuthMiddleware);
orderRouter.get(
"/me",
// #swagger.tags = ['orders']
// #swagger.description = 'Get all orders (session) of the current user'
validator(getMyOrdersSchema),
orderController.getMyOrders,
);

orderRouter.post(
"/",
/* #swagger.tags = ['orders']
#swagger.description = 'Create a new order'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/CreateOrderSchema" }
} */
Expand All @@ -37,6 +39,7 @@ orderRouter.post(
orderRouter.post(
"/:orderId/accept",
// #swagger.tags = ['orders']
// #swagger.description = 'Accept an order'
verifyTutor,
validator(changeOrderStatusSchema),
orderController.acceptOrder,
Expand All @@ -45,6 +48,7 @@ orderRouter.post(
orderRouter.post(
"/:orderId/decline",
// #swagger.tags = ['orders']
// #swagger.description = 'Decline an order'
verifyTutor,
validator(changeOrderStatusSchema),
orderController.declineOrder,
Expand All @@ -53,6 +57,7 @@ orderRouter.post(
orderRouter.post(
"/:orderId/cancel",
// #swagger.tags = ['orders']
// #swagger.description = 'Cancel an order'
verifyTutor,
validator(changeOrderStatusSchema),
orderController.cancelOrder,
Expand All @@ -61,6 +66,7 @@ orderRouter.post(
orderRouter.get(
"/unreviewed",
// #swagger.tags = ['orders']
// #swagger.description = 'Get all unreviewed orders of the learner'
verifyLearner,
orderController.getUnreviewedOrders,
);
Expand Down
3 changes: 3 additions & 0 deletions src/module/review/review.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const reviewRouter = Router();
reviewRouter.get(
"/tutories/:tutoriesId",
// #swagger.tags = ['reviews']
// #swagger.description = 'Get reviews of a tutories'
validator(getReviewsSchema),
reviewController.getTutoriesReviews,
);
Expand All @@ -28,6 +29,7 @@ reviewRouter.use(verifyLearner);
reviewRouter.post(
"/orders/:orderId",
/* #swagger.tags = ['reviews']
#swagger.description = 'Create review for an order'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/CreateReviewSchema" }
} */
Expand All @@ -38,6 +40,7 @@ reviewRouter.post(
reviewRouter.post(
"/orders/:orderId/dismiss",
// #swagger.tags = ['reviews']
// #swagger.description = 'Dismiss review prompt'
validator(dismissReviewSchema),
reviewController.dismissReviewPrompt,
);
Expand Down
11 changes: 11 additions & 0 deletions src/module/tutories/tutories.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,38 @@ tutoriesRouter.use(jwtAuthMiddleware);
tutoriesRouter.get(
"/",
// #swagger.tags = ['tutors/services']
// #swagger.description = 'Get all tutories (tutor services)'
validator(getTutoriesSchema),
tutoriesController.getAllTutories,
);

tutoriesRouter.get(
"/avg-rate",
// #swagger.tags = ['tutors/services']
// #swagger.description = 'Get average hourly rate of tutories in specified category, city, or district)'
validator(getAverageRateSchema),
tutoriesController.getAverageRate,
);

tutoriesRouter.get(
"/locations",
// #swagger.tags = ['tutors/services']
// #swagger.description = 'Get all locations where tutories are available'
tutoriesController.getLocations,
);

tutoriesRouter.get(
"/recommendations",
// #swagger.tags = ['tutors/services']
// #swagger.description = 'Get recommended tutories for learner'
verifyLearner,
tutoriesController.getRecommendations,
);

tutoriesRouter.get(
"/interaction/:tutoriesId",
// #swagger.tags = ['tutors/services']
// #swagger.description = 'Track interaction with tutories (view)'
verifyLearner,
validator(trackInteractionSchema),
tutoriesController.trackInteraction,
Expand All @@ -55,6 +61,7 @@ tutoriesRouter.get(
tutoriesRouter.get(
"/:tutoriesId",
// #swagger.tags = ['tutors/services']
// #swagger.description = 'Get details of a tutories'
tutoriesController.getTutories,
);

Expand All @@ -65,12 +72,14 @@ tutoriesRouter.use(verifyTutor);
tutoriesRouter.get(
"/me",
// #swagger.tags = ['tutors/services']
// #swagger.description = 'Get all tutories of current logged in tutor'
tutoriesController.getMyTutories,
);

tutoriesRouter.post(
"/",
/* #swagger.tags = ['tutors/services']
#swagger.description = 'Create a new tutories (tutor service)'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/CreateTutoriesSchema" }
} */
Expand All @@ -80,6 +89,7 @@ tutoriesRouter.post(
tutoriesRouter.patch(
"/:tutoriesId",
/* #swagger.tags = ['tutors/services']
# #swagger.description = 'Update a tutories (tutor service)'
#swagger.requestBody = {
schema: { $ref: "#/components/schemas/UpdateTutoriesSchema" }
} */
Expand All @@ -89,6 +99,7 @@ tutoriesRouter.patch(
tutoriesRouter.delete(
"/:tutoriesId",
// #swagger.tags = ['tutors/services']
// #swagger.description = 'Delete a tutories (tutor service)'
tutoriesController.deleteTutories,
);

Expand Down
6 changes: 2 additions & 4 deletions src/swagger/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,10 @@ export const components = {
UpdateLearnerProfileSchema: {
name: "David Gacoan",
email: "[email protected]",
phoneNumber: "081234567890",
phoneNumber: "6281234567890",
city: "Samarinda",
district: "Samarinda Utara",
gender: "male/female",
interests: ["categoryId", "categoryId"],
learningStyle: "visual/auditory/kinesthetic",
},
UpdateTutorProfileSchema: {
name: "Dony Gacoan",
Expand All @@ -47,7 +45,7 @@ export const components = {
city: "Samarinda",
district: "Samarinda Utara",
gender: "male/female",
$availability: {
availability: {
1: ["07:00", "08:00"],
3: ["08:00", "09:00"],
6: ["10:00", "13:00"],
Expand Down

0 comments on commit 85f56b4

Please sign in to comment.