Docker 파일

This commit is contained in:
2025-12-28 14:31:12 +09:00
parent ba7a208da9
commit 6196c03e46
23 changed files with 302 additions and 355 deletions

View File

@@ -1,4 +1,4 @@
import { getDb } from '../../utils/db'
import { execute } from '../../utils/db'
export default defineEventHandler(async (event) => {
const body = await readBody(event)
@@ -10,15 +10,8 @@ export default defineEventHandler(async (event) => {
})
}
const db = getDb()
const now = new Date().toLocaleString('sv-SE', { timeZone: 'Asia/Seoul' }).replace('T', ' ')
const stmt = db.prepare(`
UPDATE thresholds
SET warning = ?, critical = ?, danger = ?, updated_at = ?
WHERE category = ? AND metric = ?
`)
let updated = 0
for (const [category, metrics] of Object.entries(body)) {
@@ -29,7 +22,6 @@ export default defineEventHandler(async (event) => {
const { warning, critical, danger } = values
// 유효성 검사
if (typeof warning !== 'number' || typeof critical !== 'number' || typeof danger !== 'number') {
continue
}
@@ -45,8 +37,16 @@ export default defineEventHandler(async (event) => {
})
}
const result = stmt.run(warning, critical, danger, now, category, metric)
if (result.changes > 0) updated++
try {
const result = await execute(`
UPDATE thresholds
SET warning = $1, critical = $2, danger = $3, updated_at = $4
WHERE category = $5 AND metric = $6
`, [warning, critical, danger, now, category, metric])
if (result > 0) updated++
} catch (e) {
// 테이블이 없는 경우 무시
}
}
}