ATC_SIMPLE/BACKEND/app/controllers/healcheck_controller.ts

39 lines
968 B
TypeScript

import type { HttpContext } from '@adonisjs/core/http'
import axios from 'axios'
export default class HealCheckController {
// GET /health-check
async check({}: HttpContext) {
try {
const linkWiki =
process.env.LINK_WIKI || 'https://logs.danielvu.com/api/wiki/page/insert?title=Dev_test'
const resWiki = await axios.post(linkWiki, {
data: 'Health checking',
healthChecking: true,
})
return {
code: resWiki.status,
data: [
{
name: 'wiki',
status: resWiki.status < 400 ? true : false,
message: resWiki.data?.message || 'Checking api wiki success',
},
],
}
} catch (error) {
console.log(error)
return {
code: 200,
data: [
{
name: 'wiki',
status: false,
message: error?.message || 'Checking api wiki fail',
},
],
}
}
}
}