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:
- echo 'always-auth=true' >> ~/.npmrc
- npm set @nsd:registry https://nexus.nsd.no/repository/npm-group/
- npm install
- npm build
- npm run build
publish:
stage: publish
......@@ -27,6 +27,6 @@ publish:
- echo 'always-auth=true' >> ~/.npmrc
- npm set @nsd:registry https://nexus.nsd.no/repository/npm-group/
- npm install
- npm build
- npm run build
- echo $NEXUS_NPM_PUB_TOKEN > ~/.npmrc
- npm publish
\ No newline at end of file
......@@ -89,7 +89,7 @@ function getLogData(input: LogInput): LogSchema {
query: req.query,
path: req.params
}
if (input.logRequestPayload) {
if (input.logRequestPayload && res.request.payload) {
res.request.payload = stringify(req.body, input.maxStringSize);
}
res.url = req.url;
......@@ -98,9 +98,11 @@ function getLogData(input: LogInput): LogSchema {
const response = input.response;
if (response) {
res.response = {
headers: extractHeaders(response.headers),
body: limitStringSize(response.body, input.maxStringSize)
};
headers: extractHeaders(response.headers)
}
if (response.body) {
res.response.body = limitStringSize(response.body, input.maxStringSize)
}
}
if (input.data) {
res.data = stringify(input.data, input.maxStringSize);
......
{
"name": "@nsd/log-schema-node",
"version": "3.2.0",
"version": "3.2.1",
"main": "lib/index.js",
"types": "lib/index",
"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