@@ -37,19 +37,21 @@ async function getClient() {
37
37
/**
38
38
* Creates a new event in Bus API
39
39
* 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
42
42
* @param {Object } logger object
43
43
* @return {Promise } new event promise
44
44
*/
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 ) } ` ) ;
48
47
return getClient ( ) . then ( ( busClient ) => {
49
48
logger . debug ( 'calling bus-api' ) ;
50
49
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,
53
55
} ) . then ( ( resp ) => {
54
56
logger . debug ( 'Sent event to bus-api' ) ;
55
57
logger . debug ( `Sent event to bus-api [data]: ${ resp . data } ` ) ;
0 commit comments