import { auth } from '@/auth' /** * Retrieves the authenticated user ID or throws an Unauthorized error. * Use this in Server Actions and API routes to eliminate the repetitive * `const session = await auth(); if (!session?.user?.id) ...` boilerplate. * * @throws {Error} 'Unauthorized' if no valid session exists. * @returns The authenticated user's ID string. */ export async function requireAuth(): Promise { const session = await auth() if (!session?.user?.id) { throw new Error('Unauthorized') } return session.user.id }