import prisma from '~/lib/prisma';

export default defineEventHandler(async (event) => {
  try {
    const chartes = await prisma.charte.findMany(); 

    if (!chartes || chartes.length === 0) {
      return {
        success: false,
        data: null, 
        message: 'No chartes found.',
      };
    }

    return {
      success: true,
      data: chartes,
    };
  } catch (error) {
    console.error('Error fetching chartes:', error);
    return {
      success: false,
      error: error.message,
    };
  }
});
