Files
seguidorDeLotes/nuxt4/server/api/lotes/[id].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

45 lines
863 B
TypeScript

import { getLoteById } from '~/server/utils/queries'
/**
* GET /api/lotes/:id
* Obtiene un lote específico por su ID
*/
export default defineEventHandler(async (event) => {
try {
const id = getRouterParam(event, 'id')
if (!id) {
throw createError({
statusCode: 400,
statusMessage: 'ID de lote requerido',
})
}
const lote = await getLoteById(id)
if (!lote) {
throw createError({
statusCode: 404,
statusMessage: 'Lote no encontrado',
})
}
return {
success: true,
data: lote,
}
} catch (error: any) {
console.error('Error obteniendo lote:', error)
if (error.statusCode) {
throw error
}
throw createError({
statusCode: 500,
statusMessage: 'Error obteniendo lote',
data: { message: error.message },
})
}
})