tom-microservice 3.5.2 → 3.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/routes.js +6 -4
package/package.json
CHANGED
package/src/routes.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { get, eq, forEach } = require('lodash')
|
|
4
|
+
const { buffer, text } = require('http-body')
|
|
4
5
|
const requestIp = require('request-ip')
|
|
5
|
-
const { text } = require('http-body')
|
|
6
6
|
const toQuery = require('to-query')()
|
|
7
7
|
const Router = require('router-http')
|
|
8
8
|
const send = require('./send')
|
|
@@ -21,11 +21,13 @@ const UNAUTHENTICATED_PATHS = [
|
|
|
21
21
|
]
|
|
22
22
|
|
|
23
23
|
const getBody = async req => {
|
|
24
|
-
|
|
24
|
+
if (req.path === '/payment/webhook') return buffer(req)
|
|
25
|
+
const body = await text(req)
|
|
26
|
+
if (body === '') return body
|
|
25
27
|
try {
|
|
26
|
-
return JSON.parse(
|
|
28
|
+
return JSON.parse(body)
|
|
27
29
|
} catch (_) {
|
|
28
|
-
return
|
|
30
|
+
return body
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
|