Commit f64c31b5 authored by Eirik Alvær's avatar Eirik Alvær

Avoids trying of stringify undefined request payload and response body in ExpressLogger.

parent 60b5bd7c
Pipeline #23924 failed with stage
in 17 seconds
...@@ -15,7 +15,7 @@ test: ...@@ -15,7 +15,7 @@ test:
- echo 'always-auth=true' >> ~/.npmrc - echo 'always-auth=true' >> ~/.npmrc
- npm set @nsd:registry https://nexus.nsd.no/repository/npm-group/ - npm set @nsd:registry https://nexus.nsd.no/repository/npm-group/
- npm install - npm install
- npm build - npm run build
publish: publish:
stage: publish stage: publish
...@@ -27,6 +27,6 @@ publish: ...@@ -27,6 +27,6 @@ publish:
- echo 'always-auth=true' >> ~/.npmrc - echo 'always-auth=true' >> ~/.npmrc
- npm set @nsd:registry https://nexus.nsd.no/repository/npm-group/ - npm set @nsd:registry https://nexus.nsd.no/repository/npm-group/
- npm install - npm install
- npm build - npm run build
- echo $NEXUS_NPM_PUB_TOKEN > ~/.npmrc - echo $NEXUS_NPM_PUB_TOKEN > ~/.npmrc
- npm publish - npm publish
\ No newline at end of file
...@@ -89,7 +89,7 @@ function getLogData(input: LogInput): LogSchema { ...@@ -89,7 +89,7 @@ function getLogData(input: LogInput): LogSchema {
query: req.query, query: req.query,
path: req.params path: req.params
} }
if (input.logRequestPayload) { if (input.logRequestPayload && res.request.payload) {
res.request.payload = stringify(req.body, input.maxStringSize); res.request.payload = stringify(req.body, input.maxStringSize);
} }
res.url = req.url; res.url = req.url;
...@@ -98,9 +98,11 @@ function getLogData(input: LogInput): LogSchema { ...@@ -98,9 +98,11 @@ function getLogData(input: LogInput): LogSchema {
const response = input.response; const response = input.response;
if (response) { if (response) {
res.response = { res.response = {
headers: extractHeaders(response.headers), headers: extractHeaders(response.headers)
body: limitStringSize(response.body, input.maxStringSize) }
}; if (response.body) {
res.response.body = limitStringSize(response.body, input.maxStringSize)
}
} }
if (input.data) { if (input.data) {
res.data = stringify(input.data, input.maxStringSize); res.data = stringify(input.data, input.maxStringSize);
......
{ {
"name": "@nsd/log-schema-node", "name": "@nsd/log-schema-node",
"version": "3.2.0", "version": "3.2.1",
"main": "lib/index.js", "main": "lib/index.js",
"types": "lib/index", "types": "lib/index",
"scripts": { "scripts": {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment