Files
seguidorDeLotes/nuxt4/server/api/operaciones/index.get.ts
josedario87 ee3dffa38e
Some checks failed
build-and-deploy / build-and-deploy (push) Failing after 1m47s
Implementar sistema completo de trazabilidad de lotes
- Agregar PostgreSQL 16 con esquema completo
- Crear API endpoints para lotes y operaciones
- Implementar UI con Nuxt UI (tablas, formularios, trazabilidad)
- Agregar datos de ejemplo del flujo completo
- Documentar sistema en PLAN_TRAZABILIDAD.md
2025-11-21 18:39:04 -06:00

38 lines
1020 B
TypeScript

import { getOperaciones } from '~/server/utils/queries'
/**
* GET /api/operaciones
* Lista todas las operaciones con filtros opcionales
*
* Query params:
* - tipo: filtrar por tipo de operación (ingreso, despulpado, oreado, etc.)
* - limit: límite de resultados
* - offset: offset para paginación
*/
export default defineEventHandler(async (event) => {
try {
const query = getQuery(event)
const filtros = {
tipo: query.tipo as string | undefined,
limit: query.limit ? parseInt(query.limit as string) : undefined,
offset: query.offset ? parseInt(query.offset as string) : undefined,
}
const operaciones = await getOperaciones(filtros)
return {
success: true,
data: operaciones,
count: operaciones.length,
}
} catch (error: any) {
console.error('Error obteniendo operaciones:', error)
throw createError({
statusCode: 500,
statusMessage: 'Error obteniendo operaciones',
data: { message: error.message },
})
}
})