blob: f6cc39bd958eb7330239823708333ffa8413241e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
//
// ~~~ device configs
//
// imports
import { readFileSync } from "node:fs"
import type DevicesConfig from "@lib/config/devices.types.ts"
// load config
const configFile = "data/devices.json"
let devicesConfig: DevicesConfig = {}
try {
devicesConfig = JSON.parse(readFileSync(configFile, "utf8"))
} catch(e) {
console.error("!> cannot read devices config")
}
// get all devices
const allDevices = Object.keys(devicesConfig).map((device) => {
const deviceInfo = devicesConfig[device]
return {
...deviceInfo,
id: device
}
})
export default allDevices
|