Files
system-monitor/backend/api/settings/thresholds.get.ts
2025-12-28 14:31:12 +09:00

30 lines
676 B
TypeScript

import { query } from '../../utils/db'
export default defineEventHandler(async () => {
let rows: any[] = []
try {
rows = await query(`
SELECT category, metric, warning, critical, danger, updated_at
FROM thresholds
ORDER BY category, metric
`)
} catch (e) {
rows = []
}
const result: Record<string, Record<string, { warning: number; critical: number; danger: number }>> = {}
for (const row of rows) {
if (!result[row.category]) {
result[row.category] = {}
}
result[row.category][row.metric] = {
warning: row.warning,
critical: row.critical,
danger: row.danger
}
}
return result
})