deps: Upgrade formidable to 2.0.1

This commit is contained in:
Richard Hansen 2022-01-28 21:16:05 -05:00
parent 6009fdf979
commit 5520161088
4 changed files with 53 additions and 26 deletions

View file

@ -2,22 +2,23 @@
const log4js = require('log4js');
const clientLogger = log4js.getLogger('client');
const formidable = require('formidable');
const {Formidable} = require('formidable');
const apiHandler = require('../../handler/APIHandler');
const util = require('util');
exports.expressPreSession = async (hookName, {app}) => {
// The Etherpad client side sends information about how a disconnect happened
app.post('/ep/pad/connection-diagnostic-info', (req, res) => {
new formidable.IncomingForm().parse(req, (err, fields, files) => {
new Formidable().parse(req, (err, fields, files) => {
clientLogger.info(`DIAGNOSTIC-INFO: ${fields.diagnosticInfo}`);
res.end('OK');
});
});
const parseJserrorForm = async (req) => await new Promise((resolve, reject) => {
const form = new formidable.IncomingForm();
form.maxFileSize = 1; // Files are not expected. Not sure if 0 means unlimited, so 1 is used.
const form = new Formidable({
maxFileSize: 1, // Files are not expected. Not sure if 0 means unlimited, so 1 is used.
});
form.on('error', (err) => reject(err));
form.parse(req, (err, fields) => err != null ? reject(err) : resolve(fields.errorInfo));
});