import { auth } from "@/lib/auth" import { redirect } from "next/navigation" import { prisma } from "@/lib/prisma" import Link from "next/link" import PhotoThumbnail from "@/components/PhotoThumbnail" import DeletePhotoButton from "@/components/DeletePhotoButton" import { logger } from "@/lib/logger" // Enable caching for this page export const revalidate = 60 // Revalidate every 60 seconds export default async function PhotosPage() { // DEBUG level: only logs in development or when LOG_LEVEL=DEBUG logger.debug("PhotosPage: Starting, calling auth()") const session = await auth() if (!session) { logger.debug("PhotosPage: No session, redirecting to login") redirect("/login") } if (!session.user) { // WARN level: session exists but no user is a warning condition logger.warn("PhotosPage: Session exists but no user, redirecting to login", { hasSession: !!session, sessionKeys: session ? Object.keys(session) : [], }) redirect("/login") } logger.debug("PhotosPage: Session valid, rendering page", { userId: session.user.id, userEmail: session.user.email, }) // Limit to 50 photos per page for performance const photos = await prisma.photo.findMany({ take: 50, orderBy: { createdAt: "desc" }, include: { uploader: { select: { name: true, }, }, }, }) return (
No photos yet. Be the first to upload one!
Uploaded by {photo.uploader.name}
{photo.points} {photo.points === 1 ? "pt" : "pts"}{new Date(photo.createdAt).toLocaleDateString()}