import { healthChecks } from "#start/health.ts"
import { middleware } from "#start/kernel.ts"
import type { HttpContext } from "@adonisjs/core/http"
import router from "@adonisjs/core/services/router"
export default class get_health_controller {
public async handle(context: HttpContext) {
const report = await healthChecks.run()
if (report.isHealthy) {
return context.response.ok(report)
}
return context.response.serviceUnavailable(report)
router.get("/health", [get_health_controller]).use(middleware.appKeySecurity())