-
-
Notifications
You must be signed in to change notification settings - Fork 637
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create health checks controller when configuring health checks
- Loading branch information
1 parent
75b0cf9
commit f494c52
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{#var controllerName = generators.controllerName(entity.name, false)}} | ||
{{#var controllerFileName = generators.controllerFileName(entity.name, false)}} | ||
{{{ | ||
exports({ | ||
to: app.httpControllersPath(entity.path, controllerFileName) | ||
}) | ||
}}} | ||
import { healthChecks } from '#start/health' | ||
import type { HttpContext } from '@adonisjs/core/http' | ||
|
||
export default class {{ controllerName }} { | ||
async handle({ response }: HttpContext) { | ||
const report = await healthChecks.run() | ||
|
||
if (report.isHealthy) { | ||
return response.ok(report) | ||
} | ||
|
||
return response.serviceUnavailable(report) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters