17 lines
532 B
TypeScript
17 lines
532 B
TypeScript
|
import { healthChecks } from "#start/health.js"
|
||
|
import { middleware } from "#start/kernel.js"
|
||
|
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())
|