mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: better healthcheck
This commit is contained in:
parent
6cd1cf7e9c
commit
46f016f661
8 changed files with 112 additions and 9 deletions
33
apps/web/services/utils/health.ts
Normal file
33
apps/web/services/utils/health.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { getAPIUrl } from '@services/config/config'
|
||||
import {
|
||||
RequestBody,
|
||||
getResponseMetadata,
|
||||
} from '@services/utils/ts/requests'
|
||||
|
||||
export async function checkHealth() {
|
||||
try {
|
||||
const result = await fetch(
|
||||
`${getAPIUrl()}health`,
|
||||
RequestBody('GET', null, null)
|
||||
)
|
||||
|
||||
if (!result.ok) {
|
||||
return {
|
||||
success: false,
|
||||
status: result.status,
|
||||
HTTPmessage: result.statusText,
|
||||
data: null
|
||||
}
|
||||
}
|
||||
|
||||
const res = await getResponseMetadata(result)
|
||||
return res
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
status: 503,
|
||||
HTTPmessage: 'Service unavailable',
|
||||
data: null
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue