Skip to content

Instantly share code, notes, and snippets.

@samuelteixeiras
Created March 23, 2022 23:19
Show Gist options
  • Save samuelteixeiras/1375bf8378e12475823da1c6c92deaed to your computer and use it in GitHub Desktop.
Save samuelteixeiras/1375bf8378e12475823da1c6c92deaed to your computer and use it in GitHub Desktop.
failure Notification endpoint
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