Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/common/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ module.exports = {
newAuthError: msg => new AppError(401, msg || 'Auth failed.'),
newPermissionError: msg => new AppError(403, msg || 'The entity does not exist.'),
newConflictError: msg => new AppError(409, msg || 'The entity does not exist.'),
serviceUnavailableError: msg => new AppError(503, msg || 'One or more services are not available'),
elasticSearchEnrichError: msg => new AppError(500, msg || 'Elasticsearch enrich failed')
}
11 changes: 11 additions & 0 deletions src/modules/health/controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* the role controller
*/

const service = require('./service')
const helper = require('../../common/helper')
const methods = helper.getControllerMethods(service)

module.exports = {
...methods
}
12 changes: 12 additions & 0 deletions src/modules/health/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* the health routes
*/

const Controller = require('./controller')
module.exports = {
'/health': {
get: {
method: Controller.get
}
}
}
17 changes: 17 additions & 0 deletions src/modules/health/service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const errors = require('../../common/errors')
const models = require('../../models')

async function get () {
// Check QLDB Connection by retrieving a session
try {
const session = await models.DBHelper.getSession()

session.close()
} catch (e) {
throw errors.serviceUnavailableError(`QLDB is unavailable, ${e.message}`)
}

return { checksRun: 1 }
}

module.exports = { get }