var formidable = require("formidable");
const path = require('path');

export async function parseFormParam(req, res, next) {
    var form = new formidable.IncomingForm();
    form.uploadDir = path.join(__dirname.substring(0,__dirname.indexOf("out")), 'files');
    form.parse(req, (err, fields, files)=>{
        if (err) {
            next(err)
        }
        else {
            req.fields = fields;
            req.files = files;
            next();
        }
    })
}