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
29 changed files with 7436 additions and 6386 deletions

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;