Skip to content

Commit

Permalink
implement added methods into routes file
Browse files Browse the repository at this point in the history
  • Loading branch information
amitamrutiya committed Nov 8, 2023
1 parent 97dfce3 commit 41003fc
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
2 changes: 1 addition & 1 deletion backend/controllers/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ exports.getAllUserDetails = async (req, res) => {
try {
//get id
const { id } = req.user;

console.log("id", id);
//validation and get user details
if (!id) {
return res.status(400).json({
Expand Down
16 changes: 8 additions & 8 deletions backend/routes/Course.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const {
createCourse,
getAllCourses,
getCourseDetails,
// getFullCourseDetails,
// editCourse,
// getInstructorCourses,
// deleteCourse,
getFullCourseDetails,
editCourse,
getInstructorCourses,
deleteCourse,
} = require("../controllers/Course"); // Course Controllers Import

const {
Expand Down Expand Up @@ -54,10 +54,10 @@ router.post("/deleteSubSection", auth, isInstructor, deleteSubSection);
router.post("/addSubSection", auth, isInstructor, createSubSection);
router.get("/getAllCourses", getAllCourses);
router.post("/getCourseDetails", getCourseDetails);
// router.post("/editCourse", auth, isInstructor, editCourse);
// router.get("/getInstructorCourses", auth, isInstructor, getInstructorCourses);
// router.post("/getFullCourseDetails", auth, getFullCourseDetails);
// router.delete("/deleteCourse", deleteCourse);
router.post("/editCourse", auth, isInstructor, editCourse);
router.get("/getInstructorCourses", auth, isInstructor, getInstructorCourses);
router.post("/getFullCourseDetails", auth, getFullCourseDetails);
router.delete("/deleteCourse", deleteCourse);

// Category routes (Only by Admin)
router.post("/createCategory", auth, isAdmin, createCategory);
Expand Down
10 changes: 4 additions & 6 deletions backend/routes/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ const router = express.Router();

const { auth, isInstructor } = require("../middlewares/auth");
const {
// deleteAccount,
updateProfile,
getAllUserDetails,
updateDisplayPicture,
// getEnrolledCourses,
// instructorDashboard,
getEnrolledCourses,
instructorDashboard,
} = require("../controllers/Profile");

// Profile routes
router.put("/updateProfile", auth, updateProfile);
// router.get("/getEnrolledCourses", auth, getEnrolledCourses);
router.get("/getEnrolledCourses", auth, getEnrolledCourses);
router.put("/updateDisplayPicture", auth, updateDisplayPicture);
// router.get("/instructorDashboard", auth, isInstructor, instructorDashboard);
router.get("/instructorDashboard", auth, isInstructor, instructorDashboard);

module.exports = router;
2 changes: 1 addition & 1 deletion backend/routes/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ router.post("/reset-password-token", resetPasswordToken);
router.post("/reset-password", resetPassword);

// User routes
router.delete("/delete-account", auth, deleteUserAccount);
router.delete("/deleteUserAccount", auth, deleteUserAccount);
router.get("/getUserDetails", auth, getAllUserDetails);

module.exports = router;
18 changes: 18 additions & 0 deletions backend/utils/secToDuration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Helper function to convert total seconds to the duration format
function convertSecondsToDuration(totalSeconds) {
const hours = Math.floor(totalSeconds / 3600);
const minutes = Math.floor((totalSeconds % 3600) / 60);
const seconds = Math.floor((totalSeconds % 3600) % 60);

if (hours > 0) {
return `${hours}h ${minutes}m`;
} else if (minutes > 0) {
return `${minutes}m ${seconds}s`;
} else {
return `${seconds}s`;
}
}

module.exports = {
convertSecondsToDuration,
};

0 comments on commit 41003fc

Please sign in to comment.