text: const formidable = require('formidable');
  const fs = require('fs');
  const path = require('path');
  const uuidv1 = require('uuid/v1');
  
  module.exports = (parser, ...names) => {
    if (typeof parser !== 'function') {
      names.push(parser);
      parser = false;
    }
  
    return async (req, res, next) => {
      var form = new formidable.IncomingForm();
  
      form.on('fileBegin', function(name, file) {
        file.path = path.join(form.uploadDir, path.basename(file.path));
  
        res.on('finish', () => {
          fs.unlinkSync(file.path);
        });
      });
  
      form.parse(req, function(err, fields, files) {
        if (!err)
          names.forEach(name => {
            if (parser)
              req.body[name] = parser(name, fields[name] || files[name] || null);
            else req.body[name] = fields[name] || files[name] || null;
          });
        next();
      });
    };
  };
  