Comparing version 2.0.0-beta.4 to 2.0.0-beta.5
const getCallbackHandler = require('./handleCallback') | ||
const parseEvent = require('./utils/parseEvent') | ||
@@ -24,37 +25,4 @@ function handleMessage (type, response, message) { | ||
let event = { | ||
eventId: message.properties.messageId, | ||
eventType: message.fields.routingKey, | ||
resource: message.properties.appId, | ||
data: messageContent | ||
} | ||
const event = parseEvent(message.properties, message.fields, messageContent) | ||
if (message.properties.headers) { | ||
if (message.properties.headers.uuid) { | ||
event.eventId = message.properties.headers.uuid | ||
} | ||
if (message.properties.headers.scheduled) { | ||
event.scheduled = new Date(message.properties.headers.scheduled) | ||
} | ||
if (message.properties.headers.delay) { | ||
event.delay = message.properties.headers.delay | ||
} | ||
if (message.properties.headers.trace) { | ||
event.resourceTrace = message.properties.headers.trace | ||
} | ||
} | ||
if (message.properties.timestamp) { | ||
if (message.properties.timestamp.toString().length === 10) { | ||
message.properties.timestamp *= 1000 | ||
} | ||
event.timestamp = new Date(message.properties.timestamp) | ||
} | ||
event.started = new Date() | ||
response._emitter.once('done', getCallbackHandler.apply(remit, [type, response, message, event])) | ||
@@ -61,0 +29,0 @@ type._emitter.emit('data', event, callback) |
@@ -6,2 +6,3 @@ const debug = require('debug')('remit:request') | ||
const uuid = require('uuid') | ||
const parseEvent = require('./utils/parseEvent') | ||
@@ -193,4 +194,8 @@ function RequestType (masterOptions) { | ||
type._emitter.emit('sent', data) | ||
request._emitter.emit('sent', data) | ||
const sentEvent = parseEvent(messageOptions, { | ||
routingKey: options.event | ||
}, data) | ||
type._emitter.emit('sent', sentEvent) | ||
request._emitter.emit('sent', sentEvent) | ||
}) | ||
@@ -216,3 +221,3 @@ | ||
if (type.options.expectReply) { | ||
request._emitter.on('data', a => cleanUp(null, a)) | ||
request._emitter.on('data', cleanUp) | ||
request._emitter.on('timeout', cleanUp) | ||
@@ -219,0 +224,0 @@ } else { |
{ | ||
"name": "remit", | ||
"version": "2.0.0-beta.4", | ||
"version": "2.0.0-beta.5", | ||
"description": "A small set of functionality used to create microservices that don't need to be aware of one-another's existence.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
139008
42
1585