I have been working on creating a web hook listener for Mailgun, and I encountered an issue when I realized that Mailgun can post webhooks using either multipart or x-www-form-urlencoded content-types.
Currently, my code uses Multer to handle multipart but it cannot handle x-www-form-urlencoded, so I also tried using BodyParser which handles x-www-form-urlencoded but not multipart.
My question is straightforward: How can I modify my webhook listener to support both content types (multipart and x-www-form-urlencoded) effectively?
var express = require('express');
var multer = require('multer');
var app = express();
app.set('port', process.env.PORT || 3000);
app.post('/parse', multer().any(), function (req, res) {
var contentType = req.get('Content-Type');
console.log(contentType);
res.sendStatus(200);
});
var server = app.listen(app.get('port'), function() {
console.log('Listening on port %d', server.address().port);
});