Skip to content

Instantly share code, notes, and snippets.

@Dirrk
Created April 1, 2016 14:37
Show Gist options
  • Save Dirrk/fe664c448435e472ffd10afa35925ebf to your computer and use it in GitHub Desktop.
Save Dirrk/fe664c448435e472ffd10afa35925ebf to your computer and use it in GitHub Desktop.
'use strict';
/*
npm install hapi@8.x.x
node thisfile.js
curl -XPOST http://localhost:4000/v1/lead/property
*/
var Hapi = require('hapi');
var server = new Hapi.Server();
var count = 0;
server.connection({ port: 4000 });
server.route([
{
method: 'POST',
path: '/v1/lead/property',
handler: function (request, reply) {
count++;
if (count % 2 === 0) {
return reply({success: true});
}
reply(new Error('Invalid count'));
}
}
]);
server.start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment