Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/routes/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,17 @@ export const monitor = (
const url = new URL('monitor/safe', base)
return dispatchRequest<T>(url, init, headers)
}
},
{
name: 'getStatus',
action: <
T = {
connected: boolean
safe: boolean
}
>() => {
const url = new URL('monitor/status', base)
return dispatchRequest<T>(url, init, headers)
}
}
] as const
10 changes: 10 additions & 0 deletions tests/mocks/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,15 @@ export const monitorHandlers: Handler[] = [
safe: true
}
})
},
{
method: 'GET',
url: '/api/v1/monitor/status',
handler: eventHandler(_event => {
return {
connected: true,
safe: true
}
})
}
]
8 changes: 8 additions & 0 deletions tests/monitorRoutes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,13 @@ suite('@observerly/hyper Fiber API Monitor Client', () => {
if (!isDataResult(isSafe)) return
expect(isSafe).toStrictEqual({ safe: true })
})

it('should be able to determine the status of the monitor', async () => {
const client = setupClient(getURL('/api/v1/'))
const status = await client.monitor.getStatus()
expect(isDataResult(status)).toBe(true)
if (!isDataResult(status)) return
expect(status).toStrictEqual({ connected: true, safe: true })
})
})
})