I am developping a node as part of a package.
The node is a WebHook (much like what you can imagine exist in SLACK... so, the user subscribes to events and the target app will deliver those events as POST to the Webhook endpoint).
To create the endpoint I use the following in my code:
RED.httpNode.post('/thisIsMyEndpoint', bodyParser.json(), mySuccessCallback, myErrorCallback);
NOW, I need to catch the UNPARSED BODY coming from the target application, before it is parsed.
Experimenting blindly (I'm not an expert) it seems that the presence or absence of the
bodyParser.json(), parameter actually does not change the results: "mySuccessCallback" ALWAYS receives a parsed req.body object... WHich is not what I need
I tried to use something like this:
RED.httpNode.post('/thisIsMyEndpoint', myOwnFunction, mySuccessCallback, myErrorCallback);
But my own function also only receives a req, res, next and *req is already parsed.
Do you have any idea how to
- either intercept the raw body, process it and, eventually PREVENT further processing
- provide a req.raw_body attribute to the "mySuccessCallback"
Perhaps I am not using the right tools