UNPKG

@seratch_/bolt-fastify

Version:
21 lines 838 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseHTTPRequestBody = void 0; /* eslint-disable import/prefer-default-export */ const querystring_1 = require("querystring"); // eslint-disable-next-line @typescript-eslint/no-explicit-any function parseHTTPRequestBody(req) { const bodyAsString = req.rawBody.toString(); const contentType = req.headers['content-type']; if (contentType === 'application/x-www-form-urlencoded') { const parsedQs = (0, querystring_1.parse)(bodyAsString); const { payload } = parsedQs; if (typeof payload === 'string') { return JSON.parse(payload); } return parsedQs; } return JSON.parse(bodyAsString); } exports.parseHTTPRequestBody = parseHTTPRequestBody; //# sourceMappingURL=request-parser.js.map