@middy/http-response-serializer
Advanced tools
Comparing version 1.0.0-beta.5 to 1.0.0-beta.6
@@ -255,2 +255,23 @@ const createError = require('http-errors') | ||
}) | ||
test('It should return false when response body is falsey', async () => { | ||
const handler = middy((event, context, cb) => { | ||
cb(null, false) | ||
}) | ||
const event = { | ||
headers: { | ||
Accept: 'text/plain' | ||
} | ||
} | ||
handler.use(httpResponseSerializer(standardConfiguration)) | ||
const response = await invoke(handler, event) | ||
expect(response).toEqual({ | ||
headers: { | ||
'Content-Type': 'text/plain' | ||
}, | ||
body: false | ||
}) | ||
}) | ||
}) |
@@ -45,4 +45,4 @@ const Accept = require('accept') | ||
// if the response is null or undefined, normalizes it back to an object | ||
handler.response = handler.response || {} | ||
// if the response is not an object, assign it to body. { body: undefined } is not serialized | ||
handler.response = typeof handler.response === 'object' ? handler.response : { body: handler.response } | ||
@@ -49,0 +49,0 @@ // set header |
{ | ||
"name": "@middy/http-response-serializer", | ||
"version": "1.0.0-beta.5", | ||
"version": "1.0.0-beta.6", | ||
"description": "The Http Serializer middleware lets you define serialization mechanisms based on the current content negotiation.", | ||
@@ -53,6 +53,6 @@ "engines": { | ||
"devDependencies": { | ||
"@middy/core": "^1.0.0-beta.5", | ||
"@middy/core": "^1.0.0-beta.6", | ||
"es6-promisify": "^6.0.2" | ||
}, | ||
"gitHead": "15f97b9e96fe0218d954d7190b16517909c8bdef" | ||
"gitHead": "a9adee5afd272ddb20bff07c0576a7aa17f6e22c" | ||
} |
17808
9
304