This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
wikipedia-game-solver/apps/api/src/app/routes/health/get.ts

17 lines
532 B
TypeScript
Raw Normal View History

2024-08-12 19:19:43 +02:00
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())