| 27 | const uptimeObject: Map<string, UptimeEntry[]> = loadUptimeObject(); |
| 28 | |
| 29 | function loadUptimeObject(): Map<string, UptimeEntry[]> { |
| 30 | const filePath = process.env.JANK_UPTIME_JSON_PATH || path.join(__dirname, "..", "uptime.json"); |
| 31 | if (fs.existsSync(filePath)) { |
| 32 | try { |
| 33 | const data = JSON.parse(fs.readFileSync(filePath, "utf8")); |
| 34 | return new Map(Object.entries(data)); |
| 35 | } catch (error) { |
| 36 | console.error("Error reading uptime.json:", error); |
| 37 | return new Map(); |
| 38 | } |
| 39 | } |
| 40 | return new Map(); |
| 41 | } |
| 42 | |
| 43 | let saveTimeout: ReturnType<typeof setTimeout> | null = null; |
| 44 | |