Skip to content

Instantly share code, notes, and snippets.

@TBD
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save TBD/19bfc2ff544b2788f0d5 to your computer and use it in GitHub Desktop.

Select an option

Save TBD/19bfc2ff544b2788f0d5 to your computer and use it in GitHub Desktop.
hapi testing
var Hapi = require('hapi');
var http = require('request-promise');
var Promise = require('promise')
var pdf = require('html-pdf')
var server = new Hapi.Server();
server.connection({ port: 3000 });
server.route({
method: 'GET',
path: '/',
handler: function (request, reply) {
function p(html){
return new Promise(function(resolve, reject){
pdf.create(html).toBuffer(function(err,res){
console.log('*** converting to pdf')
resolve(res)
})
})
}
function x(pdf){
reply(pdf).type('application/pdf')
}
http('http://www.google.com').then(p).then(x)
}
});
server.start(function () {
console.log('Server running at:', server.info.uri);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment