Implementar sistema completo de trazabilidad de lotes
Some checks failed
build-and-deploy / build-and-deploy (push) Failing after 1m47s
Some checks failed
build-and-deploy / build-and-deploy (push) Failing after 1m47s
- 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
This commit is contained in:
37
nuxt4/server/api/lotes/index.get.ts
Normal file
37
nuxt4/server/api/lotes/index.get.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { getLotes } from '~/server/utils/queries'
|
||||
|
||||
/**
|
||||
* GET /api/lotes
|
||||
* Lista todos los lotes con filtros opcionales
|
||||
*
|
||||
* Query params:
|
||||
* - tipo: filtrar por tipo de lote (uva, despulpado_primera, 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 lotes = await getLotes(filtros)
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: lotes,
|
||||
count: lotes.length,
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('Error obteniendo lotes:', error)
|
||||
throw createError({
|
||||
statusCode: 500,
|
||||
statusMessage: 'Error obteniendo lotes',
|
||||
data: { message: error.message },
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user