Some checks failed
build-and-deploy / build-and-deploy (push) Failing after 1m4s
- Cambiar imports de ~/server/utils a rutas relativas - Fix build error en Docker - Build local verificado exitosamente
38 lines
1017 B
TypeScript
38 lines
1017 B
TypeScript
import { getOperaciones } from '../../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 },
|
|
})
|
|
}
|
|
})
|