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"
class Controller {
public async handle(context: HttpContext): Promise<void> {
const report = await healthChecks.run()
if (report.isHealthy) {
return context.response.ok(report)
}
return context.response.serviceUnavailable(report)
router.get("/health", [Controller]).use(middleware.appKeySecurity())