title: Node.js: wait for zip file to be generated and send response
body: <p>I am generating a zip file using the module <code>archiver</code>. I want to wait for the zip file to be generated before proceeding further. Below is the relevant part of the code.</p>
  <pre><code>// create a file to stream archive data to.
  const archiver = require('archiver');
  const fs =  require('fs');
  
  async function zipcsv(zipPath) {
    let output = fs.createWriteStream(zipPath);
    let archive = archiver('zip', {
      zlib: { level: 9 } // Sets the compression level.
    });
    output.on('close', function() {
     return 'zip generating complete';
    });
    archive.pipe(output);
    archive.directory('exports/', false);
    archive.finalize();
  }
  
  module.exports.zipcsv = zipcsv;
  
  </code></pre>
  <pre><code>zip = require('./zipcsv')
  await zip.zipcsv(path);
  console.log('futher processing');
  </code></pre>
  <p>I see futher processing on the console and the process does not wait for the zip to be generated and continues.</p>
  <p>How can I ensure that the zip is generated and then further processing continues.</p>
  <p>Thanks.</p>