wikipedia-game-solver/apps/api/src/app/routes/health/get.ts

17 lines
532 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"
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())