Files
Compo-Service-Log-Project/src/middlewares/xmlBodyParser.ts
T
2024-11-11 23:09:59 +01:00

14 lines
362 B
TypeScript

import { NextFunction, Request, Response } from "express";
export default function (req: Request, res: Response, next: NextFunction) {
if (req.is("application/xml")) {
let data = "";
req.setEncoding("utf8");
req.on("data", (chunk: any) => (data += chunk));
req.on("end", () => {
req.body = data;
next();
});
} else next();
}