feat : ajout page monitoring
This commit is contained in:
37
server/api/version-status.get.ts
Normal file
37
server/api/version-status.get.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
export default defineEventHandler(async () => {
|
||||
const targets = [
|
||||
{ label: "Ferme", url: "http://ferme.malio-dev.fr/api/version" },
|
||||
{ label: "SIRH", url: "http://sirh.malio-dev.fr/api/version" },
|
||||
{ label: "Inventory", url: "http://inventory.malio-dev.fr/api/health" },
|
||||
]
|
||||
|
||||
const results = await Promise.all(
|
||||
targets.map(async (target) => {
|
||||
try {
|
||||
const response = await fetch(target.url, {
|
||||
method: "GET",
|
||||
headers: { Accept: "application/json" }
|
||||
})
|
||||
|
||||
return {
|
||||
label: target.label,
|
||||
url: target.url,
|
||||
ok: response.status === 200,
|
||||
status: response.status,
|
||||
checkedAt: new Date().toISOString()
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
label: target.label,
|
||||
url: target.url,
|
||||
ok: false,
|
||||
status: 0,
|
||||
checkedAt: new Date().toISOString(),
|
||||
error: error instanceof Error ? error.message : String(error)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
return { results }
|
||||
})
|
||||
Reference in New Issue
Block a user