Browse Source

Fixed console.log & file errors

fix/clean
astria 3 months ago
parent
commit
0153419389
  1. 2
      backend/app/controllers/channel.controller.js
  2. 15
      backend/app/controllers/media.controller.js
  3. 2
      backend/app/controllers/oauth.controller.js
  4. 2
      backend/app/controllers/search.controller.js
  5. 12
      backend/app/controllers/user.controller.js
  6. 8
      backend/app/controllers/video.controller.js
  7. 2
      backend/app/middlewares/error.middleware.js
  8. 2
      backend/app/middlewares/video.middleware.js
  9. BIN
      backend/app/uploads/profiles/astri6.jpg
  10. BIN
      backend/app/uploads/profiles/astri7.jpg
  11. BIN
      backend/app/uploads/profiles/astria.png
  12. BIN
      backend/app/uploads/profiles/astria2.jpg
  13. BIN
      backend/app/uploads/profiles/astria3.jpg
  14. BIN
      backend/app/uploads/profiles/default.png
  15. 4
      backend/app/utils/database.js
  16. 72
      backend/logs/access.log
  17. 7
      backend/server.js
  18. 2
      backend/test/playlist.test.js
  19. 4
      backend/tools.js
  20. 2
      developpement.yaml
  21. 4
      docker-compose.yaml
  22. 2
      frontend/src/components/CreatorCard.jsx
  23. 2
      frontend/src/components/Recommendations.jsx
  24. 2
      frontend/src/modals/CreateChannelModal.jsx
  25. 2
      frontend/src/modals/EmailVerificationModal.jsx
  26. 4
      frontend/src/pages/AddVideo.jsx
  27. 6
      frontend/src/pages/LoginSuccess.jsx
  28. 4
      frontend/src/pages/ManageVideo.jsx
  29. 2
      frontend/src/pages/Register.jsx
  30. 22
      frontend/src/pages/Video.jsx
  31. 2
      frontend/src/services/channel.service.js
  32. 4
      frontend/src/services/user.service.js
  33. BIN
      uploads/profiles/sacha.jpg

2
backend/app/controllers/channel.controller.js

@ -236,7 +236,7 @@ export async function getStats(req, res) {
client.release();
res.status(200).json(result.rows[0]);
} catch (error) {
console.log(error);
res.status(500).json({error: error.message});
}

15
backend/app/controllers/media.controller.js

@ -15,12 +15,13 @@ export async function getProfilePicture(req, res) {
path.join('/app/uploads/profiles', file)
];
console.log('Possible paths:', possiblePaths);
console.log('Current working directory:', process.cwd());
console.log('__dirname:', __dirname);
// Try the most likely path first (based on your volume mapping)
const filePath = path.join(__dirname, '../../uploads/profiles', file);
console.log(path.join(__dirname, '../uploads/profiles', file))
const filePath = path.join(__dirname, '../uploads/profiles', file);
try {
res.sendFile(filePath, (err) => {
@ -28,7 +29,7 @@ export async function getProfilePicture(req, res) {
console.error("Error sending profile picture:", err);
res.status(404).json({ error: "Profile picture not found." });
} else {
console.log("Profile picture sent successfully.");
}
});
} catch (error) {
@ -47,7 +48,7 @@ export async function getThumbnail(req, res) {
console.error("Error sending thumbnail:", err);
res.status(404).json({ error: "Thumbnail not found." });
} else {
console.log("Thumbnail sent successfully.");
}
});
} catch (error) {
@ -65,7 +66,7 @@ export async function getVideo(req, res) {
if (err) {
console.error("Error sending video:", err);
} else {
console.log("Video sent successfully.");
}
});
} catch (error) {

2
backend/app/controllers/oauth.controller.js

@ -26,7 +26,7 @@ export async function callback(req, res, next) {
const avatarUrl = user.photos && user.photos[0] ? user.photos[0].value : null;
const displayName = user.displayName || username;
console.log(user);
console.log("GitHub user info:", {
githubId,

2
backend/app/controllers/search.controller.js

@ -2,7 +2,7 @@ import {getClient} from "../utils/database.js";
export async function search(req, res) {
try {
console.log(req.query);
const query = req.query.q;
const type = req.query.type || 'all';
const offset = parseInt(req.query.offset) || 0;

12
backend/app/controllers/user.controller.js

@ -111,7 +111,7 @@ export async function register(req, res) {
</html>
`;
console.log("Sending email to:", user.email);
await sendEmail(user.email, "🎬 Bienvenue sur Freetube - Vérifiez votre email", textMessage, htmlMessage);
@ -122,11 +122,11 @@ export async function register(req, res) {
const insertQuery = `INSERT INTO email_verification (email, token, expires_at) VALUES ($1, $2, $3)`;
await client.query(insertQuery, [user.email, token, expirationDate]);
console.log("Successfully registered");
logger.write("successfully registered", 200);
res.status(200).send({ user: user });
} catch (err) {
console.log(err);
logger?.write("failed to register user", 500);
res.status(500).json({ error: "Internal server error" });
} finally {
@ -217,7 +217,7 @@ export async function login(req, res) {
logger.write("Successfully logged in", 200);
res.status(200).json({ token: token, user: userData });
} catch (err) {
console.log(err);
logger?.write("failed to login", 500);
res.status(500).json({ error: "Internal server error" });
} finally {
@ -317,7 +317,7 @@ export async function update(req, res) {
let __filename = fileURLToPath(import.meta.url);
let __dirname = dirname(__filename);
console.log(__dirname);
let profilePicture = userInBase.picture.split("/").pop();
fs.rename(
@ -338,7 +338,7 @@ export async function update(req, res) {
client.release();
res.status(200).json(result.rows[0]);
} catch (err) {
console.log(err);
client.release()
res.status(500).json({ error: err });
}

8
backend/app/controllers/video.controller.js

@ -74,7 +74,7 @@ export async function upload(req, res) {
if (Array.isArray(authorizedUsers) && authorizedUsers.length > 0) {
for (let i = 0; i < authorizedUsers.length; i++) {
const user = authorizedUsers[i];
console.log("authorized user", user);
const query = `INSERT INTO video_authorized_users (video_id, user_id) VALUES ($1, $2)`;
// SEND EMAIL TO AUTHORIZED USER
@ -565,7 +565,7 @@ export async function getLikesPerDay(req, res) {
const resultLikes = await client.query(likeQuery, [id]);
response.likes = resultLikes.rows;
console.log(response);
logger.write("successfully retrieved likes per day", 200);
res.status(200).json(response);
@ -607,14 +607,14 @@ export async function updateAuthorizedUsers(req, res) {
const { authorizedUsers } = req.body;
console.log(authorizedUsers);
const client = await getClient();
try {
// Remove all existing authorized users
const deleteQuery = `DELETE FROM video_authorized_users WHERE video_id = $1`;
console.log(`DELETE FROM video_authorized_users WHERE video_id = ${id}`);
await client.query(deleteQuery, [id]);
// Add new authorized users

2
backend/app/middlewares/error.middleware.js

@ -6,7 +6,7 @@ export default async function validator(req, res, next) {
if (!errors.isEmpty()) {
const logger = req.body.logger;
logger.write("failed due to invalid values", 400);
console.log(req.body);
return res.status(400).json({ errors: errors.array() });
} else {
next()

2
backend/app/middlewares/video.middleware.js

@ -150,7 +150,7 @@ export async function hasAccess(req, res, next) {
const videoResult = await client.query(videoQuery, [videoId]);
const video = videoResult.rows[0];
console.log(video);
if (video.visibility === 'private') {
const token = req.headers.authorization?.split(" ")[1];

BIN
backend/app/uploads/profiles/astri6.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

BIN
backend/app/uploads/profiles/astri7.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

BIN
backend/app/uploads/profiles/astria.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 MiB

BIN
backend/app/uploads/profiles/astria2.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

BIN
backend/app/uploads/profiles/astria3.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

BIN
backend/app/uploads/profiles/default.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

4
backend/app/utils/database.js

@ -22,7 +22,7 @@ export async function getClient() {
// Graceful shutdown
process.on('SIGINT', () => {
pool.end(() => {
console.log('Pool has ended');
process.exit(0);
});
});
@ -151,7 +151,7 @@ export async function initDb() {
await client.query(`ALTER TABLE users ALTER COLUMN email DROP NOT NULL`);
await client.query(`ALTER TABLE users ALTER COLUMN password DROP NOT NULL`);
} catch (e) {
console.log("OAuth columns already exist or error adding them:", e.message);
}
} catch (e) {

72
backend/logs/access.log

@ -12162,3 +12162,75 @@
[2025-09-06 10:23:54.352] [undefined] GET(/:id): Successfully get channel with id 2 with status 200
[2025-09-06 10:23:54.364] [undefined] GET(/:id/channel/subscribed): check if user 1 is subscribed to channel 2
[2025-09-06 10:23:54.370] [undefined] GET(/:id/channel/subscribed): user 1 is not subscribed to channel 2 with status 200
[2025-09-08 16:38:02.990] [undefined] POST(/): failed because email already exists with status 400
[2025-09-08 16:38:11.467] [undefined] POST(/): failed because email already exists with status 400
[2025-09-08 16:38:28.340] [undefined] POST(/): failed because email already exists with status 400
[2025-09-08 16:39:29.271] [undefined] POST(/): try to register a user with username: astria and email: sachaguerin.sg@gmail.com
[2025-09-08 16:39:31.245] [undefined] POST(/): successfully registered with status 200
[2025-09-08 16:39:43.524] [undefined] POST(/verify-email): try to verify email for sachaguerin.sg@gmail.com with token 86155
[2025-09-08 16:39:43.543] [undefined] POST(/verify-email): successfully verified email for sachaguerin.sg@gmail.com with status 200
[2025-09-08 16:39:50.092] [undefined] POST(/login): try to login with username 'astria'
[2025-09-08 16:39:50.164] [undefined] POST(/login): Successfully logged in with status 200
[2025-09-08 16:39:50.339] [undefined] GET(/see-later): 'See Later' playlist retrieved for user with id 1 with status 200
[2025-09-08 16:39:53.065] [undefined] GET(/:id/history): try to retrieve history of user 1
[2025-09-08 16:39:53.069] [undefined] GET(/:id/channel): try to retrieve channel of user 1
[2025-09-08 16:39:53.077] [undefined] GET(/:id/history): failed to retrieve history of user 1 because it doesn't exist with status 404
[2025-09-08 16:39:53.084] [undefined] GET(/:id/channel): failed to retrieve channel of user 1 because it doesn't exist with status 404
[2025-09-08 16:39:53.095] [undefined] GET(/user/:id): Playlists retrieved for user with id 1 with status 200
[2025-09-08 16:43:38.736] [undefined] POST(/): try to register a user with username: sacha and email: thelolshow974@gmail.com
[2025-09-08 16:43:40.388] [undefined] POST(/): successfully registered with status 200
[2025-09-08 16:43:55.477] [undefined] POST(/verify-email): try to verify email for thelolshow974@gmail.com with token dd574
[2025-09-08 16:43:55.494] [undefined] POST(/verify-email): successfully verified email for thelolshow974@gmail.com with status 200
[2025-09-08 16:44:02.186] [undefined] POST(/login): try to login with username 'sacha'
[2025-09-08 16:44:02.255] [undefined] POST(/login): Successfully logged in with status 200
[2025-09-08 16:44:02.388] [undefined] GET(/see-later): 'See Later' playlist retrieved for user with id 2 with status 200
[2025-09-08 16:44:04.504] [undefined] GET(/:id/channel): try to retrieve channel of user 2
[2025-09-08 16:44:04.508] [undefined] GET(/:id/channel): failed to retrieve channel of user 2 because it doesn't exist with status 404
[2025-09-08 16:44:04.517] [undefined] GET(/:id/history): try to retrieve history of user 2
[2025-09-08 16:44:04.523] [undefined] GET(/:id/history): failed to retrieve history of user 2 because it doesn't exist with status 404
[2025-09-08 16:44:04.537] [undefined] GET(/user/:id): Playlists retrieved for user with id 2 with status 200
[2025-09-08 16:45:13.811] [undefined] GET(/:id/channel): try to retrieve channel of user 2
[2025-09-08 16:45:13.816] [undefined] GET(/:id/channel): failed to retrieve channel of user 2 because it doesn't exist with status 404
[2025-09-08 16:45:13.824] [undefined] GET(/:id/history): try to retrieve history of user 2
[2025-09-08 16:45:13.829] [undefined] GET(/:id/history): failed to retrieve history of user 2 because it doesn't exist with status 404
[2025-09-08 16:45:13.838] [undefined] GET(/user/:id): Playlists retrieved for user with id 2 with status 200
[2025-09-08 16:46:03.637] [undefined] GET(/:id/channel): try to retrieve channel of user 2
[2025-09-08 16:46:03.643] [undefined] GET(/:id/channel): failed to retrieve channel of user 2 because it doesn't exist with status 404
[2025-09-08 16:46:03.650] [undefined] GET(/:id/history): try to retrieve history of user 2
[2025-09-08 16:46:03.656] [undefined] GET(/:id/history): failed to retrieve history of user 2 because it doesn't exist with status 404
[2025-09-08 16:46:03.666] [undefined] GET(/user/:id): Playlists retrieved for user with id 2 with status 200
[2025-09-08 16:46:17.413] [undefined] GET(/:id/history): try to retrieve history of user 2
[2025-09-08 16:46:17.417] [undefined] GET(/:id/channel): try to retrieve channel of user 2
[2025-09-08 16:46:17.426] [undefined] GET(/:id/channel): failed to retrieve channel of user 2 because it doesn't exist with status 404
[2025-09-08 16:46:17.431] [undefined] GET(/:id/history): failed to retrieve history of user 2 because it doesn't exist with status 404
[2025-09-08 16:46:17.442] [undefined] GET(/user/:id): Playlists retrieved for user with id 2 with status 200
[2025-09-08 16:46:35.561] [undefined] GET(/:id/channel): try to retrieve channel of user 2
[2025-09-08 16:46:35.567] [undefined] GET(/:id/channel): failed to retrieve channel of user 2 because it doesn't exist with status 404
[2025-09-08 16:46:35.576] [undefined] GET(/:id/history): try to retrieve history of user 2
[2025-09-08 16:46:35.583] [undefined] GET(/:id/history): failed to retrieve history of user 2 because it doesn't exist with status 404
[2025-09-08 16:46:35.595] [undefined] GET(/user/:id): Playlists retrieved for user with id 2 with status 200
[2025-09-08 16:47:27.440] [undefined] GET(/:id/channel): try to retrieve channel of user 2
[2025-09-08 16:47:27.445] [undefined] GET(/:id/channel): failed to retrieve channel of user 2 because it doesn't exist with status 404
[2025-09-08 16:47:27.454] [undefined] GET(/:id/history): try to retrieve history of user 2
[2025-09-08 16:47:27.459] [undefined] GET(/:id/history): failed to retrieve history of user 2 because it doesn't exist with status 404
[2025-09-08 16:47:27.469] [undefined] GET(/user/:id): Playlists retrieved for user with id 2 with status 200
[2025-09-08 16:47:49.574] [undefined] POST(/login): try to login with username 'sacha'
[2025-09-08 16:47:49.634] [undefined] POST(/login): Successfully logged in with status 200
[2025-09-08 16:47:49.727] [undefined] GET(/see-later): 'See Later' playlist retrieved for user with id 2 with status 200
[2025-09-08 16:47:51.469] [undefined] GET(/:id/channel): try to retrieve channel of user 2
[2025-09-08 16:47:51.474] [undefined] GET(/:id/channel): failed to retrieve channel of user 2 because it doesn't exist with status 404
[2025-09-08 16:47:51.482] [undefined] GET(/:id/history): try to retrieve history of user 2
[2025-09-08 16:47:51.492] [undefined] GET(/:id/history): failed to retrieve history of user 2 because it doesn't exist with status 404
[2025-09-08 16:47:51.503] [undefined] GET(/user/:id): Playlists retrieved for user with id 2 with status 200
[2025-09-08 16:48:31.139] [undefined] GET(/:id/channel): try to retrieve channel of user 2
[2025-09-08 16:48:31.145] [undefined] GET(/:id/channel): failed to retrieve channel of user 2 because it doesn't exist with status 404
[2025-09-08 16:48:31.153] [undefined] GET(/:id/history): try to retrieve history of user 2
[2025-09-08 16:48:31.160] [undefined] GET(/user/:id): failed because user doesn't exists with status 404
[2025-09-08 16:48:31.165] [undefined] GET(/:id/history): failed to retrieve history of user 2 because it doesn't exist with status 404
[2025-09-08 16:49:08.966] [undefined] POST(/): try to register a user with username: astria and email: sachaguerin.sg@gmail.com
[2025-09-08 16:49:10.628] [undefined] POST(/): successfully registered with status 200
[2025-09-08 16:49:20.080] [undefined] POST(/verify-email): try to verify email for sachaguerin.sg@gmail.com with token fe65c
[2025-09-08 16:49:20.097] [undefined] POST(/verify-email): successfully verified email for sachaguerin.sg@gmail.com with status 200
[2025-09-08 16:49:30.515] [undefined] POST(/login): try to login with username 'astria'
[2025-09-08 16:49:30.577] [undefined] POST(/login): Successfully logged in with status 200
[2025-09-08 16:49:30.682] [undefined] GET(/see-later): 'See Later' playlist retrieved for user with id 1 with status 200

7
backend/server.js

@ -22,7 +22,7 @@ import { Strategy as GitHubStrategy } from "passport-github2";
console.clear();
dotenv.config();
console.log(process.env)
const app = express();
@ -96,10 +96,11 @@ const port = process.env.BACKEND_PORT;
if (process.env.NODE_ENV !== "test") {
const server = http.createServer(app);
server.listen(port, '0.0.0.0', async () => {
console.log("Server's listening on port " + port);
console.log("Initializing database...");
console.log(`Server started on port ${port}`);
await initDb();
console.log("Database initialized successfully.");
});
}

2
backend/test/playlist.test.js

@ -53,7 +53,7 @@ describe('ADD VIDEO TO PLAYLIST', () => {
it("Should return 404 if playlist does not exist", async () => {
const req = await request(app).post(`/api/playlists/${falseplaylistId}`).set("Authorization", `Bearer ${token}`).send({ video: videoId });
console.log(req.body);
expect(req.statusCode).toBe(404);
})

4
backend/tools.js

@ -1,6 +1,6 @@
import pg from "pg";
console.log(process.argv[2]);
if (process.argv[2] === "flush") {
@ -20,7 +20,7 @@ async function flushDatabase() {
try {
await client.connect();
await client.query('TRUNCATE TABLE users CASCADE');
console.log('Database flushed successfully.');
} catch (err) {
console.error('Error flushing database:', err);
} finally {

2
developpement.yaml

@ -15,7 +15,7 @@ services:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
JWT_SECRET: ${JWT_SECRET}
LOG_FILE: ${LOG_FILE}
PORT: ${BACKEND_PORT}
BACKEND_PORT: ${BACKEND_PORT}
GMAIL_USER: ${GMAIL_USER}
GMAIL_PASSWORD: ${GMAIL_PASSWORD}
GITHUB_ID: ${GITHUB_ID}

4
docker-compose.yaml

@ -15,7 +15,7 @@ services:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
JWT_SECRET: ${JWT_SECRET}
LOG_FILE: ${LOG_FILE}
PORT: ${BACKEND_PORT}
BACKEND_PORT: ${BACKEND_PORT}
GMAIL_USER: ${GMAIL_USER}
GMAIL_PASSWORD: ${GMAIL_PASSWORD}
GITHUB_ID: ${GITHUB_ID}
@ -23,7 +23,7 @@ services:
FRONTEND_URL: ${FRONTEND_URL}
volumes:
- ./backend/logs:/var/log/freetube
- upload:/app/backend/app/uploads
- ./uploads:/app/app/uploads/
depends_on:
db:
condition: service_healthy

2
frontend/src/components/CreatorCard.jsx

@ -5,7 +5,7 @@ export default function CreatorCard({ creator }) {
window.location.href = `/channel/${creator.channel_id}`;
};
console.log(creator);
return (
<div className="flex flex-col glassmorphism w-full p-6 cursor-pointer" onClick={handleClick}>

2
frontend/src/components/Recommendations.jsx

@ -1,7 +1,7 @@
import VideoCard from "./VideoCard";
export default function Recommendations({videos}) {
console.log(videos);
return (
<div className="">
<h2 className="text-3xl font-bold mb-4 text-white">Recommandations</h2>

2
frontend/src/modals/CreateChannelModal.jsx

@ -22,7 +22,7 @@ export default function CreateChannelModal({isOpen, onClose, addAlert}) {
const data = await createChannel(body, token, addAlert);
console.log(data);
onClose();
}

2
frontend/src/modals/EmailVerificationModal.jsx

@ -17,7 +17,7 @@ export default function EmailVerificationModal({ isOpen, onSubmit, onClose }) {
onChange={(e) => setVerificationCode(e.target.value)}
/>
<button className="bg-primary px-3 py-2 rounded-sm text-white font-montserrat text-lg font-semibold cursor-pointer mt-2" onClick={() => {
console.log("Verification code submitted:", verificationCode);
onSubmit(verificationCode)
}}>Vérifier</button>
</div>

4
frontend/src/pages/AddVideo.jsx

@ -35,7 +35,7 @@ export default function AddVideo() {
const fetchChannel = async () => {
const fetchedChannel = await getChannel(user.id, token, addAlert);
setChannel(fetchedChannel.channel);
console.log(fetchedChannel.channel);
}
const handleTagKeyDown = (e) => {
@ -123,7 +123,7 @@ export default function AddVideo() {
// Call the API to search for users
searchByUsername(searchUser, token, addAlert)
.then((results) => {
console.log(results);
setSearchResults(results);
})
.catch((error) => {

6
frontend/src/pages/LoginSuccess.jsx

@ -15,14 +15,14 @@ export default function LoginSuccess() {
const token = searchParams.get('token');
const userParam = searchParams.get('user');
console.log('Processing OAuth callback:', { token: !!token, userParam: !!userParam });
if (token && userParam) {
try {
hasProcessed.current = true;
const userData = JSON.parse(decodeURIComponent(userParam));
console.log('Parsed user data:', userData);
// Use the OAuth login method to update auth context
loginWithOAuth(userData, token);
@ -40,7 +40,7 @@ export default function LoginSuccess() {
}, 100);
}
} else {
console.log('Missing token or user data');
hasProcessed.current = true;
setTimeout(() => {
navigate('/login?error=missing_data', { replace: true });

4
frontend/src/pages/ManageVideo.jsx

@ -173,7 +173,7 @@ export default function ManageVideo() {
channel: video.channel
};
console.log("Sending to API:", body); // Debug log
// Debug log
const request = await updateAuthorizedUsers(id, body, token, addAlert);
@ -188,7 +188,7 @@ export default function ManageVideo() {
}
const onRemoveAuthorizedUser = async (user) => {
console.log("Êtes-vous sûr de vouloir supprimer cet utilisateur autorisé ?", user.id);
const body = {
authorizedUsers: video.authorizedUsers.filter(u => u.id !== user.id),
channel: video.channel

2
frontend/src/pages/Register.jsx

@ -77,7 +77,7 @@ export default function Register() {
const onVerificationSubmit = async (token) => {
console.log("Submitting email verification with token:", token);
const response = await verifyEmail(formData.email, token, addAlert);

22
frontend/src/pages/Video.jsx

@ -84,32 +84,32 @@ export default function Video() {
const token = localStorage.getItem('token');
if (!token) return;
console.log("Fetching next video");
console.log("currentPlaylist", currentPlaylist);
console.log("current video id from params:", id, "type:", typeof id);
console.log("playlist videos:", currentPlaylist?.videos?.map(v => ({ id: v.id, type: typeof v.id })));
//Find position of current video id in currentPlaylist.videos
const currentIndex = currentPlaylist?.videos.findIndex(video => {
console.log(`Comparing video.id: ${video.id} (${typeof video.id}) with id: ${id} (${typeof id})`);
return video.id.toString() === id.toString();
});
console.log("currentIndex", currentIndex);
if (currentIndex !== -1) {
if (currentPlaylist?.videos[currentIndex + 1]) {
setNextVideo(currentPlaylist.videos[currentIndex + 1]);
console.log("nextVideo", currentPlaylist.videos[currentIndex + 1]);
}
}
}
const passToNextVideo = () => {
if (!nextVideo) {
console.log("No next video available");
return;
}
console.log("Passing to next video:", nextVideo);
// Navigate to the next video with playlist context
if (playlistId) {
@ -209,7 +209,7 @@ export default function Video() {
const handlePlaying = () => {
if (videoRef.current) {
console.log(`Video is playing at ${videoRef.current.currentTime} seconds`);
}
}
@ -249,7 +249,7 @@ export default function Video() {
const response = await subscribe(video.creator.id, addAlert);
console.log('Subscription successful:', response);
const subscriptionCount = response.subscriptions || 0;
setVideo((prevVideo) => {

2
frontend/src/services/channel.service.js

@ -56,7 +56,7 @@ export async function updateChannel(channelId, data, token, addAlert) {
export async function subscribe(channelId, addAlert) {
const token = localStorage.getItem('token');
const user = JSON.parse(localStorage.getItem('user'));
console.log("Subscribing to channel with ID:", channelId, "for user:", user.id);
return fetch(`/api/channels/${channelId}/subscribe`, {
method: 'POST',
headers: {

4
frontend/src/services/user.service.js

@ -11,7 +11,7 @@ export async function isSubscribed(channelId, addAlert) {
const request = await fetch(`/api/users/${channelId}/channel/subscribed`, { headers })
const result = await request.json();
console.log("Subscription status for channel ID", channelId, ":", result);
return result.subscribed;
}
@ -140,7 +140,7 @@ export async function searchByUsername(username, token, addAlert) {
});
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
console.log(errorData);
throw new Error(errorData.error || "Failed to search user");
}
const data = await response.json();

BIN
uploads/profiles/sacha.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Loading…
Cancel
Save