wikipedia-game-solver/apps/api/app/controllers/health/get_health_controller.ts

17 lines
554 B
TypeScript
Raw Normal View History

2024-08-15 15:14:21 +02:00
import { healthChecks } from "#start/health.ts"
import { middleware } from "#start/kernel.ts"
2024-08-12 19:19:43 +02:00
import type { HttpContext } from "@adonisjs/core/http"
import router from "@adonisjs/core/services/router"
2024-08-16 02:50:11 +02:00
export default class get_health_controller {
public async handle(context: HttpContext) {
2024-08-12 19:19:43 +02:00
const report = await healthChecks.run()
if (report.isHealthy) {
return context.response.ok(report)
}
return context.response.serviceUnavailable(report)
}
}
2024-08-16 02:50:11 +02:00
router.get("/health", [get_health_controller]).use(middleware.appKeySecurity())