text: const { createGzip, createDeflate } = require('zlib')
  module.exports = (resource, req, res) => {
    const acceptEncoding = req.headers['accept-encoding']
    if (!acceptEncoding || !acceptEncoding.match(/\b(gzip|deflate)\b/)) {
      return resource
    } else if (acceptEncoding.match(/\bgzip\b/)) {
      res.setHeader('Content-Encoding', 'gzip')
      return resource.pipe(createGzip())
    } else if (acceptEncoding.match(/\bdeflate\b/)) {
      res.setHeader('Content-Encoding', 'gzip')
      return resource.pipe(createDeflate())
    }
  }
  