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

28 lines
673 B
TypeScript

import { getDb } from '../../utils/db'
export default defineEventHandler(() => {
const db = getDb()
const rows = db.prepare(`
SELECT category, metric, warning, critical, danger, updated_at
FROM thresholds
ORDER BY category, metric
`).all() as any[]
// 카테고리별로 그룹화
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
})