Skip to content

Commit c7ec546

Browse files
Add req.body to the subscribe response as well
Signed-off-by: Xavier Geerinck <[email protected]>
1 parent e4f8245 commit c7ec546

File tree

1 file changed

+7
-2
lines changed
  • src/implementation/Server/HTTPServer

1 file changed

+7
-2
lines changed

src/implementation/Server/HTTPServer/pubsub.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@ export default class HTTPServerPubSub implements IServerPubSub {
3232
await this.server.getServerImpl().registerPubSubSubscriptionRoute(pubsubName, topic, route);
3333

3434
this.server.getServer().post(`/${route}`, async (req, res) => {
35-
// Process our callback
3635
// @ts-ignore
37-
await cb(req?.body?.data);
36+
// Parse the data of the body, we prioritize fetching the data key in body if possible
37+
// i.e. Redis returns { data: {} } and other services return {}
38+
// @todo: This will be deprecated in an upcoming major version and only req.body will be returned
39+
const data = req?.body?.data || req?.body;
40+
41+
// Process our callback
42+
await cb(data);
3843

3944
// Let Dapr know that the message was processed correctly
4045
// console.log(`[Dapr API][PubSub][route-${topic}] Ack'ing the message`);

0 commit comments

Comments
 (0)