account-lookup-service 17.11.0 → 17.11.1-snapshot.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "account-lookup-service",
3
3
  "description": "Account Lookup Service is used to validate Party and Participant lookups.",
4
- "version": "17.11.0",
4
+ "version": "17.11.1-snapshot.0",
5
5
  "license": "Apache-2.0",
6
6
  "author": "ModusBox",
7
7
  "contributors": [
@@ -96,8 +96,8 @@
96
96
  "@mojaloop/central-services-logger": "11.9.0",
97
97
  "@mojaloop/central-services-metrics": "12.6.0",
98
98
  "@mojaloop/central-services-shared": "18.29.0",
99
- "@mojaloop/central-services-stream": "11.8.0",
100
- "@mojaloop/database-lib": "11.2.0",
99
+ "@mojaloop/central-services-stream": "^11.8.0",
100
+ "@mojaloop/database-lib": "11.2.1",
101
101
  "@mojaloop/event-sdk": "14.6.1",
102
102
  "@mojaloop/inter-scheme-proxy-cache-lib": "2.6.0",
103
103
  "@mojaloop/ml-schema-transformer-lib": "2.7.1",
@@ -166,7 +166,7 @@
166
166
  "axios": "1.10.0",
167
167
  "axios-retry": "^4.5.0",
168
168
  "docdash": "2.0.2",
169
- "dotenv": "^17.0.1",
169
+ "dotenv": "^17.1.0",
170
170
  "get-port": "5.1.1",
171
171
  "ioredis-mock": "^8.9.0",
172
172
  "jest": "29.7.0",
package/src/api/health.js CHANGED
@@ -27,7 +27,7 @@
27
27
  'use strict'
28
28
 
29
29
  const HealthCheck = require('@mojaloop/central-services-shared').HealthCheck.HealthCheck
30
- const { getSubServiceHealthDatastore, getProxyCacheHealth } = require('../lib/healthCheck/subServiceHealth')
30
+ const { getSubServiceHealthDatastore, getProxyCacheHealth, getSubServiceHealthBroker } = require('../lib/healthCheck/subServiceHealth')
31
31
  const packageJson = require('../../package.json')
32
32
  const Config = require('../lib/config')
33
33
 
@@ -36,7 +36,8 @@ const getSubServices = (appConfig, isAdmin) => {
36
36
  return [getSubServiceHealthDatastore]
37
37
  }
38
38
 
39
- const subServices = [getSubServiceHealthDatastore]
39
+ const subServices = [getSubServiceHealthDatastore, getSubServiceHealthBroker]
40
+
40
41
  if (appConfig.PROXY_CACHE_CONFIG.enabled) {
41
42
  subServices.push(getProxyCacheHealth)
42
43
  }
@@ -20,14 +20,14 @@
20
20
 
21
21
  const { HealthCheck } = require('@mojaloop/central-services-shared').HealthCheck
22
22
  const { defaultHealthHandler } = require('@mojaloop/central-services-health')
23
- const { getProxyCacheHealth } = require('../../../lib/healthCheck/subServiceHealth')
23
+ const { getProxyCacheHealth, getSubServiceHealthBroker } = require('../../../lib/healthCheck/subServiceHealth')
24
24
  const packageJson = require('../../../../package.json')
25
25
 
26
26
  let healthCheck
27
27
 
28
28
  const createHealthCheck = ({ proxyCache }) => {
29
29
  return new HealthCheck(packageJson, [
30
- () => getProxyCacheHealth(proxyCache)
30
+ () => getProxyCacheHealth(proxyCache), () => getSubServiceHealthBroker()
31
31
  ])
32
32
  }
33
33
 
@@ -26,6 +26,7 @@
26
26
  const { statusEnum, serviceName } = require('@mojaloop/central-services-shared').HealthCheck.HealthCheckEnums
27
27
  const { logger } = require('../../lib')
28
28
  const MigrationLockModel = require('../../models/misc/migrationLock')
29
+ const Producer = require('@mojaloop/central-services-stream').Util.Producer
29
30
 
30
31
  /**
31
32
  * @function getSubServiceHealthDatastore
@@ -54,6 +55,28 @@ const getSubServiceHealthDatastore = async () => {
54
55
  }
55
56
  }
56
57
 
58
+ /**
59
+ * @function getSubServiceHealthBroker
60
+ *
61
+ * @description Gets the health for the Notification broker
62
+ * @returns Promise<object> The SubService health object for the broker
63
+ */
64
+ const getSubServiceHealthBroker = async () => {
65
+ let status = statusEnum.OK
66
+ try {
67
+ await Producer.allConnected()
68
+ status = statusEnum.OK
69
+ } catch (err) {
70
+ logger.isDebugEnabled && logger.debug(`getSubServiceHealthBroker failed with error: ${err.message}.`)
71
+ status = statusEnum.DOWN
72
+ }
73
+
74
+ return {
75
+ name: serviceName.broker,
76
+ status
77
+ }
78
+ }
79
+
57
80
  /**
58
81
  * @function getProxyCacheHealth
59
82
  *
@@ -79,5 +102,6 @@ const getProxyCacheHealth = async (proxyCache) => {
79
102
 
80
103
  module.exports = {
81
104
  getSubServiceHealthDatastore,
82
- getProxyCacheHealth
105
+ getProxyCacheHealth,
106
+ getSubServiceHealthBroker
83
107
  }
@@ -86,7 +86,7 @@ describe('/health', () => {
86
86
  expect(response.statusCode).toBe(200)
87
87
  const payload = JSON.parse(response.payload)
88
88
  expect(payload.status).toBe('OK')
89
- expect(payload.services.length).toBe(1)
89
+ expect(payload.services.length).toBe(2)
90
90
  expect(payload.services[0].name).toBe('datastore')
91
91
  })
92
92
 
@@ -108,7 +108,7 @@ describe('/health', () => {
108
108
  expect(response.statusCode).toBe(503)
109
109
  const payload = JSON.parse(response.payload)
110
110
  expect(payload.status).toBe('DOWN')
111
- expect(payload.services.length).toBe(1)
111
+ expect(payload.services.length).toBe(2)
112
112
  expect(payload.services[0].name).toBe('datastore')
113
113
  })
114
114
 
@@ -135,8 +135,8 @@ describe('/health', () => {
135
135
  // Assert
136
136
  const payload = JSON.parse(response.payload)
137
137
  expect(response.statusCode).toBe(200)
138
- expect(payload.services.length).toBe(2)
139
- expect(payload.services[1].name).toBe('proxyCache')
138
+ expect(payload.services.length).toBe(3)
139
+ expect(payload.services[2].name).toBe('proxyCache')
140
140
  } finally {
141
141
  serverWithProxy && await serverWithProxy.stop()
142
142
  }