-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
430ae37
commit 1cb8f80
Showing
7 changed files
with
29 additions
and
8 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
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,14 @@ | ||
import { healthChecks } from '#start/health' | ||
import type { HttpContext } from '@adonisjs/core/http' | ||
|
||
export default class HealthChecksController { | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { healthChecks } from '#start/health' | ||
import type { HttpContext } from '@adonisjs/core/http' | ||
|
||
export default class HealthchecksController { | ||
index({ response }: HttpContext) { | ||
return response.status(200).json({ | ||
status: 'ok', | ||
}) | ||
async index({ response }: HttpContext) { | ||
const health = await healthChecks.run() | ||
const check = health.checks[0] | ||
check.status | ||
return response.send(health.checks) | ||
} | ||
} |
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,5 @@ | ||
import { HealthChecks } from '@adonisjs/core/health' | ||
import { DbCheck } from '@adonisjs/lucid/database' | ||
import db from '@adonisjs/lucid/services/db' | ||
|
||
export const healthChecks = new HealthChecks().register([new DbCheck(db.connection())]) |
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