Last active
March 18, 2020 04:53
-
-
Save JulesAU/60cd18fcd5a4a0f77f49f0004afafb60 to your computer and use it in GitHub Desktop.
Receiving JSON Wormly Alerts in NodeJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Receive alerts from the Wormly Webhook Alert channel. | |
// https://www.wormly.com/help/channels/http-rpc | |
require('http').createServer(function (req, res) { | |
var alert = ''; | |
req.on('data', function (chunk) { alert += chunk.toString() }); | |
req.on('end', function () { | |
if (req.headers['content-type'] === 'application/json') { | |
alert = JSON.parse(alert); | |
} | |
console.log(alert); | |
res.end('OK'); | |
}); | |
}).listen(port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment