import { PrismaClient } from '@prisma/client';
import { User } from '../../types/auth';

const prisma = new PrismaClient();

export async function getUser(userId: string): Promise<User | null> {
  try {
    const user = await prisma.user.findUnique({
      where: { id: userId },
      select: {
        id: true,
        email: true,
        displayName: true,
        permissions: true
      }
    });

    return user as User | null;
  } catch  {
    return null;
  }
}