Files
sexy/packages/frontend/src/routes/videos/[slug]/+page.server.ts

28 lines
716 B
TypeScript
Raw Normal View History

2025-10-25 22:04:41 +02:00
import { error } from "@sveltejs/kit";
import { getCommentsForVideo, getVideoBySlug, getVideoLikeStatus } from "$lib/services.js";
2025-10-25 22:04:41 +02:00
export async function load({ fetch, params, locals }) {
const video = await getVideoBySlug(params.slug, fetch);
const comments = await getCommentsForVideo(video.id, fetch);
let likeStatus = { liked: false };
if (locals.authStatus.authenticated) {
try {
likeStatus = await getVideoLikeStatus(video.id, fetch);
} catch (error) {
console.error("Failed to get like status:", error);
}
}
try {
return {
video,
comments,
authStatus: locals.authStatus,
likeStatus,
};
} catch {
error(404, "Video not found");
}
2025-10-25 22:04:41 +02:00
}