Files
seguidorDeLotes/nuxt4/server/api/operaciones/[id].get.ts
josedario87 30a5e1aafb
Some checks failed
build-and-deploy / build-and-deploy (push) Failing after 1m4s
Corregir imports en archivos API del servidor
- Cambiar imports de ~/server/utils a rutas relativas
- Fix build error en Docker
- Build local verificado exitosamente
2025-11-21 18:46:14 -06:00

45 lines
966 B
TypeScript

import { getOperacionConLotes } from '../../utils/queries'
/**
* GET /api/operaciones/:id
* Obtiene una operación específica con sus lotes relacionados (inputs y outputs)
*/
export default defineEventHandler(async (event) => {
try {
const id = getRouterParam(event, 'id')
if (!id) {
throw createError({
statusCode: 400,
statusMessage: 'ID de operación requerido',
})
}
const operacion = await getOperacionConLotes(id)
if (!operacion) {
throw createError({
statusCode: 404,
statusMessage: 'Operación no encontrada',
})
}
return {
success: true,
data: operacion,
}
} catch (error: any) {
console.error('Error obteniendo operación:', error)
if (error.statusCode) {
throw error
}
throw createError({
statusCode: 500,
statusMessage: 'Error obteniendo operación',
data: { message: error.message },
})
}
})