trucasos para hacer tests
All checks were successful
build-and-deploy / filter (push) Successful in 2s
build-and-deploy / build (push) Successful in 8s
build-and-deploy / deploy (push) Successful in 13s

This commit is contained in:
2025-05-14 20:11:44 -06:00
parent ec40acf5b5
commit 55645d0cdd

View File

@@ -1,35 +1,31 @@
// planilla/api/server.js
import express from 'express'; import express from 'express';
import { PrismaClient } from './prisma/generated/client/index.js'; 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(); const prisma = new PrismaClient();
const app = express(); const app = express();
app.use(express.json()); app.use(express.json());
app.get('/api/test', (req, res) => res.json({ message: 'Hello World' }));
app.get('/api/test', async (req, res) => { app.post('/api/clientes/random', async (_req, res) => {
// hello world
console.log('Hello World');
res.json({ message: 'Hello World' });
});
app.post('/api/clientes/random', async (req, res) => {
try { try {
const cliente = await prisma.cliente.create({ const cliente = await prisma.cliente.create({
data: { data: {
name: 'Cliente ' + Math.floor(Math.random() * 10000), name: 'Cliente ' + Math.floor(Math.random() * 10000),
cedula: Math.floor(Math.random() * 1000000000), cedula: BigInt(Math.floor(Math.random() * 1_000_000_000)),
ubicacion: 'Río Frío', ubicacion: 'Río Frío',
empleado: true, empleado: true,
}, },
}); });
res.json(cliente); res.json(cliente); // ← ahora sí serializa
} catch (error) { } catch (err) {
console.error('❌ Error al crear cliente:', error); console.error('❌ Error al crear cliente:', err);
res.status(500).json({ error: 'Error al crear cliente' }); res.status(500).json({ error: 'Error al crear cliente' });
} }
}); });
app.listen(4000, () => console.log('API corriendo en :4000'));
app.listen(4000, ()=> console.log('API corriendo en :4000'));