Last active
August 29, 2015 14:14
-
-
Save TBD/19bfc2ff544b2788f0d5 to your computer and use it in GitHub Desktop.
hapi testing
This file contains hidden or 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
| 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