initial commit
This commit is contained in:
13
server/api/devices.get.js
Normal file
13
server/api/devices.get.js
Normal file
@@ -0,0 +1,13 @@
|
||||
import { getDb } from '../utils/db.js'
|
||||
import { requireAuth } from '../utils/authHelpers.js'
|
||||
import { rowToDevice, sanitizeDeviceForResponse } from '../utils/deviceUtils.js'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAuth(event)
|
||||
const { all } = await getDb()
|
||||
const rows = await all(
|
||||
'SELECT id, name, device_type, vendor, lat, lng, stream_url, source_type, config FROM devices ORDER BY id',
|
||||
)
|
||||
const devices = rows.map(r => rowToDevice(r)).filter(Boolean)
|
||||
return devices.map(sanitizeDeviceForResponse)
|
||||
})
|
||||
Reference in New Issue
Block a user