Skip to content

Commit 364b048

Browse files
author
sachin-maheshwari
authored
Merge pull request #104 from topcoder-platform/hotfix/upgradeBusPayload
hotfix for bus payload changes
2 parents e0f4fbe + 2842081 commit 364b048

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/services/busApi.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,21 @@ async function getClient() {
3737
/**
3838
* Creates a new event in Bus API
3939
* Any errors will be simply ignored
40-
* @param {String} type the event type, should be a dot separated fully qualitied name
41-
* @param {Object} message the message, should be a JSON object
40+
* @param {String} topic the event topic, should be a dot separated fully qualitied name
41+
* @param {Object} payload the payload, should be a JSON object
4242
* @param {Object} logger object
4343
* @return {Promise} new event promise
4444
*/
45-
function createEvent(type, message, logger) {
46-
const body = JSON.stringify(message);
47-
logger.debug(`Sending message: ${JSON.stringify(message)}`);
45+
function createEvent(topic, payload, logger) {
46+
logger.debug(`Sending message: ${JSON.stringify(payload)}`);
4847
return getClient().then((busClient) => {
4948
logger.debug('calling bus-api');
5049
return busClient.post('/bus/events', {
51-
type,
52-
message: body,
50+
topic,
51+
originator: 'tc-project-service',
52+
timestamp: (new Date()).toISOString(),
53+
'mime-type': 'application/json',
54+
payload,
5355
}).then((resp) => {
5456
logger.debug('Sent event to bus-api');
5557
logger.debug(`Sent event to bus-api [data]: ${resp.data}`);

0 commit comments

Comments
 (0)