Skip to content

Instantly share code, notes, and snippets.

@realityking
Created September 6, 2017 12:38
Show Gist options
  • Save realityking/dd2a8b9a7419a3790ea0d59eee23eaa2 to your computer and use it in GitHub Desktop.
Save realityking/dd2a8b9a7419a3790ea0d59eee23eaa2 to your computer and use it in GitHub Desktop.
Simple webhook receiver
'use strict';
const hapi = require('hapi');
const server = new hapi.Server();
// Tell our server that it will listen on port 3001
server.connection({ port: 3001 });
// Setup the route for our webhook
server.route({
method: 'POST',
path: '/webhook',
handler: function (request, reply) {
const body = request.payload;
const response = reply('Everything is A-OK!');
response.header('Content-Type', 'text/plain');
console.log(request.headers);
console.log(body);
}
});
// Start the server
server.start(function (err) {
if (err) {
throw err
}
console.log('Server started on port 3001')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment