This repository was archived by the owner on Mar 12, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Controller for health check endpoint
3
+ */
4
+ const models = require ( '../../models' )
5
+ const config = require ( 'config' )
6
+ const logger = require ( '../../common/logger' )
7
+
8
+ // the topcoder-healthcheck-dropin library returns checksRun count,
9
+ // here it follows that to return such count
10
+ let checksRun = 0
11
+
12
+ /**
13
+ * Check health of the DB
14
+ * @param {Object } req the request
15
+ * @param {Object } res the response
16
+ */
17
+ async function checkHealth ( req , res ) {
18
+ checksRun += 1
19
+ await models
20
+ . validate ( )
21
+ . then ( ( ) => {
22
+ logger . info ( { component : 'HealthCheckController' , context : 'checkHealth' , message : 'Connection has been established successfully.' } )
23
+ } )
24
+ . catch ( err => {
25
+ logger . logFullError ( err , { component : 'HealthCheckController' , context : 'checkHealth' } )
26
+ res . status ( 503 )
27
+ } )
28
+ res . send ( { checksRun } )
29
+ }
30
+
31
+ module . exports = {
32
+ checkHealth
33
+ }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * the skill routes
3
+ */
4
+
5
+ const Controller = require ( './controller' )
6
+
7
+ module . exports = {
8
+ '/health' : {
9
+ get : {
10
+ method : Controller . checkHealth
11
+ }
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments