Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit b0631fe

Browse files
Debugging messages
1 parent 0eb1b18 commit b0631fe

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@hapi/joi": "^15.1.0",
3030
"async-mutex": "^0.2.4",
3131
"aws-sdk": "^2.476.0",
32+
"axios": "^0.20.0",
3233
"bluebird": "^3.5.5",
3334
"config": "^3.1.0",
3435
"elasticsearch": "^16.7.1",

src/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ async function getLatestCount () {
3939
*/
4040
const dataHandler = (messageSet, topic, partition) => Promise.each(messageSet, async (m) => {
4141
const message = m.message.value.toString('utf8')
42+
await helper.postToWebhook({ message })
4243
logger.info(`Handle Kafka event message; Topic: ${topic}; Partition: ${partition}; Offset: ${
4344
m.offset}; Message: ${message}.`)
4445
let messageJSON

src/common/helper.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const elasticsearch = require('elasticsearch')
88
const _ = require('lodash')
99
const Joi = require('@hapi/joi')
1010
const { Mutex } = require('async-mutex')
11+
const { default: Axios } = require('axios')
1112

1213
AWS.config.region = config.ES.AWS_REGION
1314

@@ -191,6 +192,15 @@ function checkEsMutexRelease (tId) {
191192
}
192193
}
193194

195+
async function postToWebhook (data) {
196+
try {
197+
await Axios.post('https://webhook.site/249a740a-8671-4e35-a37c-321f795bff05', data)
198+
} catch (error) {
199+
console.log('Error posting to webhook')
200+
console.log(error)
201+
}
202+
}
203+
194204
module.exports = {
195205
getKafkaOptions,
196206
getESClient,
@@ -200,5 +210,6 @@ module.exports = {
200210
getOrg,
201211
updateOrg,
202212
getErrorWithStatus,
203-
checkEsMutexRelease
213+
checkEsMutexRelease,
214+
postToWebhook
204215
}

0 commit comments

Comments
 (0)