Files
system-monitor/backend/api/network/privnet/targets/[id].put.ts
2025-12-28 12:03:48 +09:00

30 lines
656 B
TypeScript

import { getDb } from '../../../../utils/db'
export default defineEventHandler(async (event) => {
const db = getDb()
const id = getRouterParam(event, 'id')
const body = await readBody(event)
const { name, url, is_active } = body
if (!name || !url) {
throw createError({
statusCode: 400,
message: 'name과 url은 필수입니다'
})
}
db.prepare(`
UPDATE privnet_targets
SET name = ?, url = ?, is_active = ?, updated_at = datetime('now', 'localtime')
WHERE id = ?
`).run(name, url, is_active ? 1 : 0, id)
return {
id: Number(id),
name,
url,
is_active: is_active ? 1 : 0
}
})