Created
January 25, 2024 19:48
-
-
Save cfjedimaster/73ad222fe89daaa6e1940376bfd5b34d to your computer and use it in GitHub Desktop.
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
/* | |
Used to debug webhook notifications. | |
Will need to be used with ngrok. | |
Thanks to Todd Sharp for the base code I modified. | |
*/ | |
import * as http from 'http'; | |
async function handler(req, res) { | |
console.log('Entered webhook handler.'); | |
let body = ''; | |
req.on('data', chunk => { | |
body += chunk.toString(); | |
}); | |
req.on('end', async () => { | |
console.log('BODY:\n', JSON.stringify(JSON.parse(body), null, '\t')); | |
// If you specified additional headers (see createpdf2.js), it will show up there: | |
console.log('HEADERS:\n',req.headers); | |
// Always respond with ack | |
res.writeHead(200, { 'Content-Type':'application/json' }); | |
res.write(JSON.stringify({'ack':'done'})); | |
res.end(); | |
}); | |
} | |
const server = http.createServer(handler); | |
server.listen(3000); | |
console.log('Listening on port 3000'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment