AI-Tennis-Coach/server/routes/users/user.js
2025-02-11 11:23:59 +05:30

59 lines
2.3 KiB
JavaScript

import express from "express";
import {
checkUploadCount,
getAnalysisOfVideo,
getUserLastRecorderVideo,
getUserPerformanceStats,
getUserRecorderVideo,
isQuizPlayed,
updateUserProfileHandler,
updateUserRecorderMiniVideo,
updateUserRecorderVideo,
uploadManualEntry,
userLogin,
userSignUp
} from "../../controller/users/index.js";
import auth from "../../middlewares/auth.js";
import upload from "../../middlewares/upload.js";
import { refreshAccessToken } from "../../helper/index.js";
const router = express.Router(); // Create a new router instance
// Route to refresh the access token
router.post('/refresh-token', refreshAccessToken);
// Route for user sign-up
router.post('/sign-up', userSignUp);
// Route for user login
router.post('/login-in', userLogin);
// Route to update user profile, requires authentication and file upload
router.patch('/update-user-profile', auth, upload.fields([{ name: 'profilePic', maxCount: 1 }]), updateUserProfileHandler);
// Route to upload a recorder video, requires authentication and checks upload count
router.post('/upload-recorder-video', auth, checkUploadCount, upload.fields([{ name: 'userVideo', maxCount: 1 }]), updateUserRecorderVideo);
// Route to get user uploaded videos, requires authentication
router.get('/get-user-uploaded', auth, getUserRecorderVideo);
// Route to get analysis by uploaded video ID, requires authentication
router.get('/get-analysis-by-uploaded-id/:id', auth, getAnalysisOfVideo);
// Route to get the last recorded video, requires authentication
router.get('/last-recorded-video', auth, getUserLastRecorderVideo);
// Route to get performance stats by week, requires authentication
router.get('/performance-stats-by-week', auth, getUserPerformanceStats);
// Route to check if a quiz has been played by the user, requires authentication
router.get('/quiz-played-by-user', auth, isQuizPlayed);
// Route to upload a manual entry, requires authentication
router.post('/upload-manual-entry', auth, uploadManualEntry);
// Route to upload a mini recorder video, requires authentication and checks upload count
router.post('/upload-mini-recorder-video', auth, checkUploadCount, upload.fields([{ name: 'userVideo', maxCount: 1 }]), updateUserRecorderMiniVideo);
export default router; // Export the router for use in other parts of the application