Created
March 23, 2022 23:19
-
-
Save samuelteixeiras/1375bf8378e12475823da1c6c92deaed to your computer and use it in GitHub Desktop.
failure Notification endpoint
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
app.post('/failureNotification', function (req, res) { | |
res = res.status(200); | |
res.send(req.body); | |
try { | |
var htmlHeader = prettyHtml(req.headers, req.body.dimensions); | |
var htmlBody = prettyHtml(JSON.parse(req.body), req.body.dimensions); | |
io.emit('chat message', '<div class="msg-header-failure">Failure Notification received at:'+ formatDate(new Date(), "dddd h:mm:sstt d MMM yyyy") +'</div>'); | |
io.emit('chat message', '<div class="header-failure">Header</div>'); | |
io.emit('chat message', htmlHeader); | |
io.emit('chat message', '<div class="msg-body-failure">Body</div>'); | |
io.emit('chat message', htmlBody); | |
} catch(e) { | |
console.log(e); | |
io.emit('chat message', '<h1>Error parsing json for a failure notification</h1>'); | |
io.emit('chat message', '<h3>Header</h3>'); | |
io.emit('chat message', htmlHeader); | |
io.emit('chat message', '<h3>Body</h3>'); | |
io.emit('chat message', req.body); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment