import { getAuthenticatedUserId } from '../../../utils/auth';

export default defineEventHandler(async (event) => {
    const userId = getAuthenticatedUserId(event);

    // Simple admin check
    if (userId !== 1) {
        throw createError({ statusCode: 403, statusMessage: 'Forbidden' });
    }

    const updatedUser = await prisma.user.update({
        where: { id: userId },
        data: {
            coins: {
                increment: 1000
            }
        }
    });

    return {
        message: 'Added 1000 coins.',
        newBalance: updatedUser.coins,
    };
});
