title: HapiJS v18: returning a zip file / stream
body: <p>I have an endpoint on my Hapi server which builds a (sometimes) large zip file.  </p>
  
  <p>I want to return that file back to the frontend, but I can't seem to figure out how to make that work in the current (18) version of Hapi. There were some MAJOR api changes recently and all the examples I can find are completely out of date.</p>
  
  <p>Some code that writes a test zip is below:</p>
  
  <pre><code>handler: async (request, h) =&gt; {
        let zip = new JSZip();
        zip.file('test.txt', 'derp derp');
        let stream = zip.generateNodeStream({streamFiles:true})
          .pipe(fs.createWriteStream('out.zip'))
          .on('finish', function () {
              // JSZip generates a readable stream with a "end" event,
              // but is piped here in a writable stream which emits a "finish" event.
              console.log("out.zip written.");
          });
  </code></pre>
  
  <p>but I cant seem to figure out what to do after.  I have tried all of the following so far:</p>
  
  <pre><code>// vanilla hapi
  return zip;
  
  // from Inert:
  return h.file(zip);
  
  // from Toys
  return Toys.stream(zip);
  
  // vanilla Hapi, take 2:
  return h.reply(zip).type('application/zip');
  </code></pre>
  
  <p>But no luck.  Ideally I'd like it to stream as the file is being built, which I have seen examples of people doing, but they were all either an outdated version of Hapi or another framework altogether.</p>
  
  <p>Thanks in advance!</p>