misc: run prettier

This commit is contained in:
lyc8503 committed 2025-04-19 21:50:43 +08:00
1 parent 751373d5dd
commit 4bcf4173ea
22 files changed
+402 -302

No files matched your search

+11 -12
View File
@@ -1,11 +1,10 @@
import { workerConfig } from "@/uptime.config"
import { MonitorState } from "@/uptime.types"
import { NextRequest } from "next/server"
import { workerConfig } from '@/uptime.config'
import { MonitorState } from '@/uptime.types'
import { NextRequest } from 'next/server'
export const runtime = 'edge'
export default async function handler(req: NextRequest): Promise<Response> {
const { UPTIMEFLARE_STATE } = process.env as unknown as {
UPTIMEFLARE_STATE: KVNamespace
}
@@ -15,11 +14,11 @@ export default async function handler(req: NextRequest): Promise<Response> {
return new Response(JSON.stringify({ error: 'No data available' }), {
status: 500,
headers: {
'Content-Type': 'application/json'
}
'Content-Type': 'application/json',
},
})
}
const state = (JSON.parse(stateStr)) as unknown as MonitorState
const state = JSON.parse(stateStr) as unknown as MonitorState
let monitors: any = {}
@@ -29,7 +28,7 @@ export default async function handler(req: NextRequest): Promise<Response> {
up: isUp,
latency: state.latency[monitor.id].recent.slice(-1)[0].ping,
location: state.latency[monitor.id].recent.slice(-1)[0].loc,
message: isUp ? "OK" : state.incident[monitor.id].slice(-1)[0].error.slice(-1)[0]
message: isUp ? 'OK' : state.incident[monitor.id].slice(-1)[0].error.slice(-1)[0],
}
}
@@ -37,12 +36,12 @@ export default async function handler(req: NextRequest): Promise<Response> {
up: state.overallUp,
down: state.overallDown,
updatedAt: state.lastUpdate,
monitors: monitors
monitors: monitors,
}
return new Response(JSON.stringify(ret), {
headers: {
'Content-Type': 'application/json'
}
'Content-Type': 'application/json',
},
})
}
}
+12 -11
View File
@@ -22,21 +22,17 @@ export default function Home({
tooltip?: string
statusPageLink?: string
}) {
let state;
let state
if (stateStr !== undefined) {
state = JSON.parse(stateStr) as MonitorState
}
// Specify monitorId in URL hash to view a specific monitor (can be used in iframe)
const monitorId = window.location.hash.substring(1);
const monitorId = window.location.hash.substring(1)
if (monitorId) {
const monitor = monitors.find((monitor) => monitor.id === monitorId);
const monitor = monitors.find((monitor) => monitor.id === monitorId)
if (!monitor || !state) {
return (
<Text fw={700}>
Monitor with id {monitorId} not found!
</Text>
)
return <Text fw={700}>Monitor with id {monitorId} not found!</Text>
}
return (
<div style={{ maxWidth: '810px' }}>
@@ -70,9 +66,14 @@ export default function Home({
)}
<Divider mt="lg" />
<Text size="xs" mt="xs" mb="xs" style={{
textAlign: 'center'
}}>
<Text
size="xs"
mt="xs"
mb="xs"
style={{
textAlign: 'center',
}}
>
Open-source monitoring and status page powered by{' '}
<a href="https://github.com/lyc8503/UptimeFlare" target="_blank">
Uptimeflare