From a53d111e5635d8e7ed666819abdc25e075aee8e3 Mon Sep 17 00:00:00 2001 From: quansenB Date: Mon, 9 Dec 2019 01:07:57 +0100 Subject: [PATCH 1/2] add xml body parser for xml webhook support --- packages/cli/package.json | 1 + packages/cli/src/Server.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/packages/cli/package.json b/packages/cli/package.json index f13f6c422c..386db9862d 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -76,6 +76,7 @@ "@oclif/errors": "^1.2.2", "basic-auth": "^2.0.1", "body-parser": "^1.18.3", + "body-parser-xml": "^1.1.0", "compression": "^1.7.4", "connect-history-api-fallback": "^1.6.0", "convict": "^5.0.0", diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 3a85221388..0593611244 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -7,6 +7,7 @@ import { getConnectionManager, } from 'typeorm'; import * as bodyParser from 'body-parser'; +require('body-parser-xml')(bodyParser); import * as history from 'connect-history-api-fallback'; import * as requestPromise from 'request-promise-native'; @@ -232,6 +233,10 @@ class App { // Support application/json type post data this.app.use(bodyParser.json({ limit: "16mb" })); + // Support application/xml type post data + // @ts-ignore + this.app.use(bodyParser.xml({ limit: "16mb" })); + // Make sure that Vue history mode works properly this.app.use(history({ rewrites: [ From ca2cc3b0cdc882308f8591d0af7123b8351cc787 Mon Sep 17 00:00:00 2001 From: quansenB Date: Mon, 9 Dec 2019 01:24:04 +0100 Subject: [PATCH 2/2] add xml2js options --- packages/cli/src/Server.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 0593611244..6620436fbe 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -235,7 +235,11 @@ class App { // Support application/xml type post data // @ts-ignore - this.app.use(bodyParser.xml({ limit: "16mb" })); + this.app.use(bodyParser.xml({ limit: "16mb", xmlParseOptions: { + normalize: true, // Trim whitespace inside text nodes + normalizeTags: true, // Transform tags to lowercase + explicitArray: false // Only put properties in array if length > 1 + } })); // Make sure that Vue history mode works properly this.app.use(history({