title: Error when trying to export more than one module.exports
body: <p>I am trying to upload an image to memory using multer, then process it with sharp and save it to disk. When I try to do multiple module.exports in my middleware.</p>
  <p>The error is:</p>
  <blockquote>
  <p>TypeError fileUpload.single is not a function</p>
  </blockquote>
  <pre><code>const multer = require(&quot;multer&quot;);
  const sharp = require(&quot;sharp&quot;);
  
  
  const MIME_TYPE_MAP = {
    &quot;image/png&quot;: &quot;png&quot;,
    &quot;image/jpg&quot;: &quot;jpg&quot;,
    &quot;image/jpeg&quot;: &quot;jpeg&quot;,
  };
  
  const multerStorage = multer.memoryStorage();
  
  const multerFilter = (req, file, cb) =&gt; {
    const isValid = !!MIME_TYPE_MAP[file.mimetype];
    let error = isValid ? null : new Error(&quot;Invalid mime type&quot;);
    cb(error, isValid);
  };
  
  const fileUpload = multer({
    storage: multerStorage,
    fileFilter: multerFilter,
  });
  
  const resizeUserPhoto = (req, res, next) =&gt; {
    if (!req.file) return next();
  
    req.file.filename = `hero-${Date.now()}`;
    sharp(req.file.buffer)
      .resize(400, 400, {
        fit: sharp.fit.outside,
      })
      .toFormat(&quot;jpeg&quot;)
      .jpeg({ quality: 80 })
      .toFile(`uploads/images/${req.file.filename}`);
  
    next();
  };
  
  module.exports = { fileUpload: fileUpload, resizeUserPhoto: resizeUserPhoto };
  </code></pre>
  <p>The route so far is:</p>
  <pre><code>const express = require(&quot;express&quot;);
  const userController = require(&quot;../controllers/userController&quot;);
  const fileUpload = require(&quot;../middleware/file-upload&quot;);
  
  router.post(
    &quot;/update-avatar&quot;,
    fileUpload.single(&quot;image&quot;),
    userController.updateAvatar
  );
  </code></pre>
  <p>When I just had the below in the route before trying to add image processing I didn't get an error;</p>
  <pre><code>module.exports = fileUpload;
  </code></pre>