[WIP] workers works! (lol) pages+migration todo
This commit is contained in:
1 parent
45d86424b2
commit
e050065a3c
15 files changed
+329
-154
No files matched your search
+1
-1
@@ -61,7 +61,7 @@ export default async function handler(req: NextRequest): Promise<Response> {
|
||||
|
||||
const state = JSON.parse(stateStr) as MonitorState
|
||||
const monitorIncidentHistory = state.incident?.[monitorId]
|
||||
const hasLatencyData = Boolean(state.latency?.[monitorId]?.recent?.length)
|
||||
const hasLatencyData = Boolean(state.latency?.[monitorId]?.length)
|
||||
|
||||
if (!monitorIncidentHistory || monitorIncidentHistory.length === 0 || !hasLatencyData) {
|
||||
return new Response(JSON.stringify(errorBadge(label, 'unknown')), {
|
||||
|
||||
+2
-2
@@ -29,8 +29,8 @@ export default async function handler(req: NextRequest): Promise<Response> {
|
||||
const isUp = state.incident[monitor.id].slice(-1)[0].end !== undefined
|
||||
monitors[monitor.id] = {
|
||||
up: isUp,
|
||||
latency: state.latency[monitor.id].recent.slice(-1)[0].ping,
|
||||
location: state.latency[monitor.id].recent.slice(-1)[0].loc,
|
||||
latency: state.latency[monitor.id].slice(-1)[0].ping,
|
||||
location: state.latency[monitor.id].slice(-1)[0].loc,
|
||||
message: isUp ? 'OK' : state.incident[monitor.id].slice(-1)[0].error.slice(-1)[0],
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -57,9 +57,7 @@ export default function Home({
|
||||
|
||||
{state == undefined ? (
|
||||
<Center>
|
||||
<Text fw={700}>
|
||||
{t('Monitor State not defined')}
|
||||
</Text>
|
||||
<Text fw={700}>{t('Monitor State not defined')}</Text>
|
||||
</Center>
|
||||
) : (
|
||||
<div>
|
||||
@@ -76,7 +74,7 @@ export default function Home({
|
||||
|
||||
export async function getServerSideProps() {
|
||||
// Read state as string from KV, to avoid hitting server-side cpu time limit
|
||||
const state = await getFromStore(process.env as any, 'state') as unknown as MonitorState
|
||||
const state = (await getFromStore(process.env as any, 'state')) as unknown as MonitorState
|
||||
|
||||
// Only present these values to client
|
||||
const monitors = workerConfig.monitors.map((monitor) => {
|
||||
|
||||
Reference in new issue
Block a user