import express from 'express'; import { PrismaClient } from './prisma/generated/client/index.js'; import { Decimal } from '@prisma/client/runtime/library.js'; BigInt.prototype.toJSON = function () { return this.toString(); }; Decimal.prototype.toJSON = function () { return this.toString(); }; const prisma = new PrismaClient(); export const app = express(); app.use(express.json()); app.get('/api/test', (req, res) => res.json({ message: 'Hello World' })); app.post('/api/clientes/random', async (_req, res) => { try { const cliente = await prisma.cliente.create({ data: { name: 'Cliente ' + Math.floor(Math.random() * 10000), cedula: BigInt(Math.floor(Math.random() * 1_000_000_000)), ubicacion: 'Río Frío', empleado: true, }, }); res.json(cliente); // ← ahora sí serializa } catch (err) { console.error('❌ Error al crear cliente:', err); res.status(500).json({ error: 'Error al crear cliente' }); } }); app.listen(4000, () => console.log('API corriendo en :4000'));