import { auth } from '@clerk/nextjs/server'; /** * Get the current Clerk user from request */ export async function getCurrentUser() { const { userId } = await auth(); return userId; } /** * Validate that user is authenticated * Throws 401 if not authenticated */ export async function requireAuth() { const { userId } = await auth(); if (!userId) { throw new Error('Unauthorized'); } return userId; } /** * Get the user's active organization (household) from Clerk */ export async function getActiveHousehold() { const { userId, orgId } = await auth(); if (!userId) { throw new Error('Unauthorized'); } if (!orgId) { throw new Error('No active household'); } return { id: orgId, userId, name: 'My Household', // TODO: Fetch actual org name from Clerk }; }