feat: upgrade libraries for dependabot alerts (#3300)

* feat: upgrade libraries and code cleanup
This commit is contained in:
lohit 2024-10-17 11:04:47 +05:30 committed by GitHub
parent bb14ec22f7
commit cc8f3de8be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 7436 additions and 6386 deletions

13309
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -51,7 +51,7 @@
"prepare": "husky install"
},
"overrides": {
"rollup":"3.29.4"
"rollup":"3.29.5"
},
"dependencies": {
"json-bigint": "^1.0.0",

View File

@ -10,6 +10,12 @@ module.exports = {
if (!isServer) {
config.resolve.fallback.fs = false;
}
Object.defineProperty(config, 'devtool', {
get() {
return 'source-map';
},
set() {},
});
return config;
},
};

View File

@ -13,27 +13,25 @@
},
"dependencies": {
"@fontsource/inter": "^5.0.15",
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.1.16",
"@prantlf/jsonlint": "^16.0.0",
"@reduxjs/toolkit": "^1.8.0",
"@tabler/icons": "^1.46.0",
"@tippyjs/react": "^4.2.6",
"@usebruno/common": "0.1.0",
"@usebruno/graphql-docs": "0.1.0",
"@usebruno/schema": "0.7.0",
"axios": "^1.5.1",
"axios": "1.7.5",
"classnames": "^2.3.1",
"codemirror": "5.65.2",
"codemirror-graphql": "1.2.5",
"cookie": "^0.6.0",
"codemirror-graphql": "2.1.1",
"cookie": "0.7.1",
"escape-html": "^1.0.3",
"file": "^0.2.2",
"file-dialog": "^0.0.8",
"file-saver": "^2.0.5",
"formik": "^2.2.9",
"github-markdown-css": "^5.2.0",
"graphiql": "^1.5.9",
"graphiql": "3.7.1",
"graphql": "^16.6.0",
"graphql-request": "^3.7.0",
"httpsnippet": "^3.0.6",
@ -44,17 +42,16 @@
"jshint": "^2.13.6",
"json5": "^2.2.3",
"jsonc-parser": "^3.2.1",
"jsonlint": "^1.6.3",
"jsonpath-plus": "^7.2.0",
"jsonpath-plus": "10.0.0",
"know-your-http-well": "^0.5.0",
"lodash": "^4.17.21",
"markdown-it": "^13.0.2",
"markdown-it-replace-link": "^1.2.0",
"mousetrap": "^1.6.5",
"nanoid": "3.3.4",
"next": "12.3.3",
"next": "14.2.15",
"path": "^0.12.7",
"pdfjs-dist": "^3.11.174",
"pdfjs-dist": "4.4.168",
"platform": "^1.3.6",
"posthog-node": "^2.1.0",
"prettier": "^2.7.1",
@ -69,7 +66,7 @@
"react-hot-toast": "^2.4.0",
"react-i18next": "^15.0.1",
"react-inspector": "^6.0.2",
"react-pdf": "^7.5.1",
"react-pdf": "9.1.1",
"react-redux": "^7.2.6",
"react-tooltip": "^5.5.2",
"sass": "^1.46.0",
@ -87,15 +84,15 @@
"@babel/preset-env": "^7.16.4",
"@babel/preset-react": "^7.16.0",
"@babel/runtime": "^7.16.3",
"autoprefixer": "^10.4.17",
"autoprefixer": "10.4.20",
"babel-loader": "^8.2.3",
"cross-env": "^7.0.3",
"css-loader": "^6.5.1",
"css-loader": "7.1.2",
"file-loader": "^6.2.0",
"html-loader": "^3.0.1",
"html-webpack-plugin": "^5.5.0",
"mini-css-extract-plugin": "^2.4.5",
"postcss": "^8.4.35",
"postcss": "8.4.47",
"style-loader": "^3.3.1",
"tailwindcss": "^3.4.1",
"webpack": "^5.64.4",

View File

@ -10,7 +10,7 @@ import { isEqual, escapeRegExp } from 'lodash';
import { getEnvironmentVariables } from 'utils/collections';
import { defineCodeMirrorBrunoVariablesMode } from 'utils/common/codemirror';
import StyledWrapper from './StyledWrapper';
import jsonlint from 'jsonlint';
import * as jsonlint from '@prantlf/jsonlint';
import { JSHINT } from 'jshint';
import stripJsonComments from 'strip-json-comments';
@ -251,17 +251,20 @@ export default class CodeEditor extends React.Component {
return found;
}
let jsonlint = window.jsonlint.parser || window.jsonlint;
jsonlint.parseError = function (str, hash) {
let loc = hash.loc;
found.push({
from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),
to: CodeMirror.Pos(loc.last_line - 1, loc.last_column),
message: str
});
};
try {
jsonlint.parse(stripJsonComments(text.replace(/(?<!"[^":{]*){{[^}]*}}(?![^"},]*")/g, '1')));
} catch (e) {}
} catch (error) {
const { message, location } = error;
const line = location?.start?.line;
const column = location?.start?.column;
if (line && column) {
found.push({
from: CodeMirror.Pos(line - 1, column),
to: CodeMirror.Pos(line - 1, column),
message
});
}
}
return found;
});
if (editor) {

View File

@ -1,19 +0,0 @@
import styled from 'styled-components';
const StyledWrapper = styled.div`
.collection-dropdown {
color: rgb(110 110 110);
&:hover {
color: inherit;
}
.tippy-box {
top: -0.5rem;
position: relative;
user-select: none;
}
}
`;
export default StyledWrapper;

View File

@ -1,60 +0,0 @@
import React, { useState, forwardRef, useRef } from 'react';
import Dropdown from '../Dropdown';
import { faCaretDown } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { IconBox, IconSearch, IconDots } from '@tabler/icons';
import StyledWrapper from './StyledWrapper';
const Navbar = () => {
const [modalOpen, setModalOpen] = useState(false);
const menuDropdownTippyRef = useRef();
const onMenuDropdownCreate = (ref) => (menuDropdownTippyRef.current = ref);
const MenuIcon = forwardRef((props, ref) => {
return (
<div ref={ref} className="dropdown-icon cursor-pointer">
<IconDots size={22} />
</div>
);
});
return (
<StyledWrapper className="px-2 py-2 flex items-center">
<div>
<span className="ml-2">Collections</span>
{/* <FontAwesomeIcon className="ml-2" icon={faCaretDown} style={{fontSize: 13}}/> */}
</div>
<div className="collection-dropdown flex flex-grow items-center justify-end">
<Dropdown onCreate={onMenuDropdownCreate} icon={<MenuIcon />} placement="bottom-start">
<div
className="dropdown-item"
onClick={(e) => {
menuDropdownTippyRef.current.hide();
setModalOpen(true);
}}
>
Create Collection
</div>
<div
className="dropdown-item"
onClick={(e) => {
menuDropdownTippyRef.current.hide();
}}
>
Import Collection
</div>
<div
className="dropdown-item"
onClick={(e) => {
menuDropdownTippyRef.current.hide();
}}
>
Settings
</div>
</Dropdown>
</div>
</StyledWrapper>
);
};
export default Navbar;

View File

@ -1,18 +0,0 @@
import styled from 'styled-components';
const Wrapper = styled.div`
.folder-list {
border: 1px solid #ccc;
border-radius: 5px;
.folder-name {
padding-block: 8px;
padding-inline: 12px;
cursor: pointer;
&:hover {
background-color: #e8e8e8;
}
}
`;
export default Wrapper;

View File

@ -1,55 +0,0 @@
import React, { useState, useEffect } from 'react';
import { faFolder } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import StyledWrapper from './StyledWrapper';
import Modal from 'components//Modal';
const SaveRequest = ({ items, onClose }) => {
const [showFolders, setShowFolders] = useState([]);
useEffect(() => {
setShowFolders(items || []);
}, [items]);
const handleFolderClick = (folder) => {
let subFolders = [];
if (folder.items && folder.items.length) {
for (let item of folder.items) {
if (item.items) {
subFolders.push(item);
}
}
if (subFolders.length) {
setShowFolders(subFolders);
}
}
};
return (
<StyledWrapper>
<Modal
size="md"
title="Save Request"
confirmText="Save"
cancelText="Cancel"
handleCancel={onClose}
handleConfirm={onClose}
>
<p className="mb-2">Select a folder to save request:</p>
<div className="folder-list">
{showFolders && showFolders.length
? showFolders.map((folder) => (
<div key={folder.uid} className="folder-name" onClick={() => handleFolderClick(folder)}>
<FontAwesomeIcon className="mr-3 text-gray-500" icon={faFolder} style={{ fontSize: 20 }} />
{folder.name}
</div>
))
: null}
</div>
</Modal>
</StyledWrapper>
);
};
export default SaveRequest;

View File

@ -7,6 +7,8 @@ import { useState } from 'react';
import 'pdfjs-dist/build/pdf.worker';
import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
import 'react-pdf/dist/esm/Page/TextLayer.css';
import { GlobalWorkerOptions } from 'pdfjs-dist/build/pdf';
GlobalWorkerOptions.workerSrc = 'pdfjs-dist/legacy/build/pdf.worker.min.mjs';
const QueryResultPreview = ({
previewTab,

View File

@ -1,74 +0,0 @@
import styled from 'styled-components';
const Wrapper = styled.div`
&.bruno-toast {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
}
.bruno-toast-card {
-webkit-animation-duration: 0.85s;
animation-duration: 0.85s;
-webkit-animation-delay: 0.1s;
animation-delay: 0.1s;
border-radius: var(--border-radius);
position: relative;
max-width: calc(100% - var(--spacing-base-unit));
margin: 3vh 10vw;
animation: fade-and-slide-in-from-top 0.5s forwards cubic-bezier(0.19, 1, 0.22, 1);
}
.notification-toast-content {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 5px;
border-radius: 4px;
}
.alert {
position: relative;
padding: 0.25rem 0.75rem;
border: 1px solid transparent;
border-radius: 0.25rem;
display: flex;
justify-content: space-between;
}
.alert-error {
color: #721c24;
background-color: #f8d7da;
border-color: #f5c6cb;
}
.alert-info {
color: #004085;
background-color: #cce5ff;
border-color: #b8daff;
}
.alert-warning {
color: #856404;
background-color: #fff3cd;
border-color: #ffeeba;
}
.alert-success {
color: #155724;
background-color: #d4edda;
border-color: #c3e6cb;
}
.closeToast {
cursor: pointer;
padding-left: 10px;
}
`;
export default Wrapper;

View File

@ -1,33 +0,0 @@
import React, { useEffect } from 'react';
import StyledWrapper from './StyledWrapper';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faTimes } from '@fortawesome/free-solid-svg-icons';
const ToastContent = ({ type, text, handleClose }) => (
<div className={`alert alert-${type}`} role="alert">
<div> {text} </div>
<div onClick={handleClose} className="closeToast">
<FontAwesomeIcon size="xs" icon={faTimes} />
</div>
</div>
);
const Toast = ({ text, type, duration, handleClose }) => {
let lifetime = duration ? duration : 3000;
useEffect(() => {
if (text) {
setTimeout(handleClose, lifetime);
}
}, [text]);
return (
<StyledWrapper className="bruno-toast">
<div className="bruno-toast-card">
<ToastContent type={type} text={text} handleClose={handleClose}></ToastContent>
</div>
</StyledWrapper>
);
};
export default Toast;

View File

@ -231,6 +231,11 @@ const GlobalStyle = createGlobalStyle`
.CodeMirror-brunoVarInfo p {
margin: 1em 0;
}
.CodeMirror-hint-active {
background: #89f !important;
color: #fff !important;
}
`;
export default GlobalStyle;

View File

@ -23,6 +23,8 @@ import '@fontsource/inter/600.css';
import '@fontsource/inter/700.css';
import '@fontsource/inter/800.css';
import '@fontsource/inter/900.css';
import { setupPolyfills } from 'utils/common/setupPolyfills';
setupPolyfills();
function SafeHydrate({ children }) {
return <div suppressHydrationWarning>{typeof window === 'undefined' ? null : children}</div>;

View File

@ -3,7 +3,6 @@ import toast from 'react-hot-toast';
import find from 'lodash/find';
import Mousetrap from 'mousetrap';
import { useSelector, useDispatch } from 'react-redux';
import SaveRequest from 'components/RequestPane/SaveRequest';
import EnvironmentSettings from 'components/Environments/EnvironmentSettings';
import NetworkError from 'components/ResponsePane/NetworkError';
import NewRequest from 'components/Sidebar/NewRequest';
@ -20,19 +19,9 @@ export const HotkeysProvider = (props) => {
const collections = useSelector((state) => state.collections.collections);
const activeTabUid = useSelector((state) => state.tabs.activeTabUid);
const isEnvironmentSettingsModalOpen = useSelector((state) => state.app.isEnvironmentSettingsModalOpen);
const [showSaveRequestModal, setShowSaveRequestModal] = useState(false);
const [showEnvSettingsModal, setShowEnvSettingsModal] = useState(false);
const [showNewRequestModal, setShowNewRequestModal] = useState(false);
const getCurrentCollectionItems = () => {
const activeTab = find(tabs, (t) => t.uid === activeTabUid);
if (activeTab) {
const collection = findCollectionByUid(collections, activeTab.collectionUid);
return collection ? collection.items : [];
}
};
const getCurrentCollection = () => {
const activeTab = find(tabs, (t) => t.uid === activeTabUid);
if (activeTab) {
@ -57,9 +46,6 @@ export const HotkeysProvider = (props) => {
dispatch(saveRequest(activeTab.uid, activeTab.collectionUid));
} else if (activeTab.type === 'collection-settings') {
dispatch(saveCollectionRoot(collection.uid));
} else {
// todo: when ephermal requests go live
// setShowSaveRequestModal(true);
}
}
}
@ -218,9 +204,6 @@ export const HotkeysProvider = (props) => {
return (
<HotkeysContext.Provider {...props} value="hotkey">
{showSaveRequestModal && (
<SaveRequest items={getCurrentCollectionItems()} onClose={() => setShowSaveRequestModal(false)} />
)}
{showEnvSettingsModal && (
<EnvironmentSettings collection={getCurrentCollection()} onClose={() => setShowEnvSettingsModal(false)} />
)}

View File

@ -24,6 +24,51 @@
--color-method-head: rgb(52 52 52);
}
*,.graphiql-container,.CodeMirror-info,.CodeMirror-lint-tooltip,reach-portal {
/* Required CSS variables after upgrading GraphiQL from v1.5.9 to v2.4.7 */
--color-primary: 0, 0%, 0% !important;
--color-secondary: 0, 0%, 0% !important;
--color-tertiary: 0, 0%, 0% !important;
--color-info: 0, 0%, 0% !important;
--color-success: 0, 0%, 0% !important;
--color-warning: 0, 0%, 0% !important;
--color-error: 0, 0%, 0% !important;
--color-neutral: 0, 0%, 0% !important;
--color-base: 0, 0%, 100% !important;
--alpha-secondary: .76;
--alpha-tertiary: .5;
--alpha-background-heavy: .15;
--alpha-background-medium: .1;
--alpha-background-light: .07;
--font-size-hint: .75rem;
--font-size-inline-code: .8125rem;
--font-size-body: .9375rem;
--font-size-h4: 1.125rem;
--font-size-h3: 1.375rem;
--font-size-h2: 1.8125rem;
--font-weight-regular: 400;
--font-weight-medium: 500;
--line-height: 1.5;
--px-2: 2px;
--px-4: 4px;
--px-6: 6px;
--px-8: 8px;
--px-10: 10px;
--px-12: 12px;
--px-16: 16px;
--px-20: 20px;
--px-24: 24px;
--border-radius-2: 2px !important;
--border-radius-4: 2px !important;
--border-radius-8: 2px !important;
--border-radius-12: 2px !important;
--popover-box-shadow: 0px 0px 1px #000 !important;
--popover-border: none;
--sidebar-width: 60px;
--toolbar-width: 40px;
--session-header-height: 51px
}
html,
body {
margin: 0;

View File

@ -0,0 +1,24 @@
export const setupPolyfills = () => {
// polyfill required to make react-pdf
if (typeof Promise.withResolvers === "undefined") {
if (typeof window !== 'undefined') {
window.Promise.withResolvers = function () {
let resolve, reject
const promise = new Promise((res, rej) => {
resolve = res
reject = rej
})
return { promise, resolve, reject }
}
} else {
global.Promise.withResolvers = function () {
let resolve, reject
const promise = new Promise((res, rej) => {
resolve = res
reject = rej
})
return { promise, resolve, reject }
}
}
}
}

View File

@ -24,12 +24,12 @@
"package.json"
],
"dependencies": {
"@aws-sdk/credential-providers": "3.525.0",
"@aws-sdk/credential-providers": "3.658.1",
"@usebruno/common": "0.1.0",
"@usebruno/js": "0.12.0",
"@usebruno/lang": "0.12.0",
"aws4-axios": "^3.3.0",
"axios": "^1.5.1",
"axios": "1.7.5",
"chai": "^4.3.7",
"chalk": "^3.0.0",
"decomment": "^0.9.5",
@ -37,12 +37,11 @@
"fs-extra": "^10.1.0",
"http-proxy-agent": "^7.0.0",
"https-proxy-agent": "^7.0.2",
"inquirer": "^9.1.4",
"json-bigint": "^1.0.0",
"lodash": "^4.17.21",
"qs": "^6.11.0",
"socks-proxy-agent": "^8.0.2",
"vm2": "^3.9.13",
"@usebruno/vm2": "^3.9.13",
"xmlbuilder": "^15.1.1",
"yargs": "^17.6.2"
}

View File

@ -22,13 +22,13 @@
"@rollup/plugin-commonjs": "^23.0.2",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-typescript": "^9.0.2",
"rollup":"3.29.4",
"rollup":"3.29.5",
"rollup-plugin-dts": "^5.0.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-terser": "^7.0.2",
"typescript": "^4.8.4"
},
"overrides": {
"rollup":"3.29.4"
"rollup":"3.29.5"
}
}

View File

@ -22,7 +22,7 @@
"modulePaths": ["node_modules"]
},
"dependencies": {
"@aws-sdk/credential-providers": "3.525.0",
"@aws-sdk/credential-providers": "3.658.1",
"@usebruno/common": "0.1.0",
"@usebruno/js": "0.12.0",
"@usebruno/lang": "0.12.0",
@ -30,7 +30,7 @@
"@usebruno/schema": "0.7.0",
"about-window": "^1.15.2",
"aws4-axios": "^3.3.0",
"axios": "^1.5.1",
"axios": "1.7.5",
"chai": "^4.3.7",
"chokidar": "^3.5.3",
"content-disposition": "^0.5.4",
@ -56,7 +56,7 @@
"socks-proxy-agent": "^8.0.2",
"tough-cookie": "^4.1.3",
"uuid": "^9.0.0",
"vm2": "^3.9.13",
"@usebruno/vm2": "^3.9.13",
"yup": "^0.32.11"
},
"optionalDependencies": {
@ -64,6 +64,6 @@
},
"devDependencies": {
"electron": "31.2.1",
"electron-builder": "23.0.2"
"electron-builder": "24.13.3"
}
}

View File

@ -19,10 +19,10 @@
"@types/react": "^18.0.25",
"graphql": "^16.6.0",
"markdown-it": "^13.0.1",
"postcss": "^8.4.18",
"postcss": "8.4.47",
"react": "18.2.0",
"react-dom": "18.2.0",
"rollup":"3.29.4",
"rollup":"3.29.5",
"rollup-plugin-dts": "^5.0.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.2",
@ -34,6 +34,6 @@
"markdown-it": "^13.0.1"
},
"overrides": {
"rollup":"3.29.4"
"rollup":"3.29.5"
}
}

View File

@ -8,7 +8,7 @@
"package.json"
],
"peerDependencies": {
"@n8n/vm2": "^3.9.23"
"@usebruno/vm2": "^3.9.13"
},
"scripts": {
"test": "node --experimental-vm-modules $(npx which jest) --testPathIgnorePatterns test.js",
@ -20,7 +20,7 @@
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"atob": "^2.1.2",
"axios": "^1.5.1",
"axios": "1.7.5",
"btoa": "^1.2.1",
"chai": "^4.3.7",
"chai-string": "^1.5.0",
@ -40,10 +40,7 @@
"@rollup/plugin-commonjs": "^23.0.2",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"rollup": "3.2.5",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-polyfill-node": "^0.13.0",
"rollup": "3.29.5",
"rollup-plugin-terser": "^7.0.2",
"stream": "^0.0.2",
"terser": "^5.31.1",

View File

@ -1,4 +1,4 @@
const { NodeVM } = require('vm2');
const { NodeVM } = require('@usebruno/vm2');
const path = require('path');
const http = require('http');
const https = require('https');

View File

@ -1,4 +1,4 @@
const { NodeVM } = require('vm2');
const { NodeVM } = require('@usebruno/vm2');
const chai = require('chai');
const path = require('path');
const http = require('http');

View File

@ -21,13 +21,13 @@
"@rollup/plugin-commonjs": "^23.0.2",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-typescript": "^9.0.2",
"rollup":"3.29.4",
"rollup":"3.29.5",
"rollup-plugin-dts": "^5.0.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-terser": "^7.0.2",
"typescript": "^4.8.4"
},
"overrides": {
"rollup":"3.29.4"
"rollup":"3.29.5"
}
}

View File

@ -25,9 +25,7 @@ tests {
const data = res.getBody();
expect(res.getBody()).to.eql({
"hello": {
"world": [
"bruno"
]
"world": ["bruno"]
}
});
});

View File

@ -18,13 +18,13 @@
},
"homepage": "https://github.com/usebruno/bruno-testbench#readme",
"dependencies": {
"axios": "^1.5.1",
"body-parser": "^1.20.0",
"axios": "1.7.5",
"body-parser": "1.20.3",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"express": "^4.18.1",
"express": "4.21.1",
"express-basic-auth": "^1.2.1",
"express-xml-bodyparser": "^0.3.0",
"fast-xml-parser": "^4.5.0",
"http-proxy": "^1.18.1",
"js-yaml": "^4.1.0",
"jsonwebtoken": "^9.0.2",

View File

@ -1,22 +1,21 @@
const express = require('express');
const bodyParser = require('body-parser');
const xmlparser = require('express-xml-bodyparser');
const cors = require('cors');
const multer = require('multer');
const authRouter = require('./auth');
const echoRouter = require('./echo');
const xmlParser = require('./utils/xmlParser');
const app = new express();
const port = process.env.PORT || 8080;
const upload = multer();
app.use(cors());
app.use(xmlparser());
app.use(xmlParser());
app.use(bodyParser.text());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
const authRouter = require('./auth');
const echoRouter = require('./echo');
app.use('/api/auth', authRouter);
app.use('/api/echo', echoRouter);

View File

@ -0,0 +1,30 @@
const { XMLParser } = require('fast-xml-parser');
const xmlParser = () => {
const parser = new XMLParser({
ignoreAttributes: false,
allowBooleanAttributes: true,
});
return (req, res, next) => {
if (req.is('application/xml') || req.is('text/xml')) {
let data = '';
req.setEncoding('utf8');
req.on('data', (chunk) => {
data += chunk;
});
req.on('end', () => {
try {
req.body = parser.parse(data);
next();
} catch (err) {
res.status(400).send('Invalid XML');
}
});
} else {
next();
}
};
};
module.exports = xmlParser;