Skip to content

Commit

Permalink
Include feedback from review.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTV12345 committed Jul 26, 2023
1 parent d818dd5 commit 4ef1f0e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
11 changes: 5 additions & 6 deletions src/node/hooks/express/openapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

const OpenAPIBackend = require('openapi-backend').default;
const IncomingForm = require('formidable').IncomingForm;
const firstValues = require('formidable').firstValues;

const cloneDeep = require('lodash.clonedeep');
const createHTTPError = require('http-errors');

Expand Down Expand Up @@ -594,17 +596,14 @@ exports.expressPreSession = async (hookName, {app}) => {

// read form data if method was POST
let formData = {};
let formDataSingle;
if (c.request.method === 'post') {
const form = new IncomingForm();
formData = (await form.parse(req))[0];
for (const k of Object.keys(formData)) {
if (formData[k] instanceof Array) {
formData[k] = formData[k][0];
}
}
formDataSingle = firstValues(form, formData);
}

const fields = Object.assign({}, header, params, query, formData);
const fields = Object.assign({}, header, params, query, formDataSingle);

if (logger.isDebugEnabled()) {
logger.debug(`REQUEST, v${version}:${funcName}, ${JSON.stringify(fields)}`);
Expand Down
33 changes: 20 additions & 13 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4ef1f0e

Please sign in to comment.