@vendia/serverless-express
Advanced tools
Comparing version 4.3.8 to 4.3.9
{ | ||
"name": "@vendia/serverless-express", | ||
"version": "4.3.8", | ||
"version": "4.3.9", | ||
"description": "This library enables you to utilize AWS Lambda and Amazon API Gateway to respond to web and API requests using your existing Node.js application framework.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -0,4 +1,40 @@ | ||
const url = require('url') | ||
const { getRequestValuesFromEvent, getMultiValueHeaders } = require('../utils') | ||
const getRequestValuesFromAlbEvent = ({ event }) => getRequestValuesFromEvent({ event }) | ||
function getPathWithQueryStringUseUnescapeParams ({ | ||
event, | ||
// NOTE: Use `event.pathParameters.proxy` if available ({proxy+}); fall back to `event.path` | ||
path = (event.pathParameters && event.pathParameters.proxy && `/${event.pathParameters.proxy}`) || event.path, | ||
// NOTE: Strip base path for custom domains | ||
stripBasePath = '', | ||
replaceRegex = new RegExp(`^${stripBasePath}`) | ||
}) { | ||
const query = {} | ||
// decode everything back into utf-8 text. | ||
if (event.multiValueQueryStringParameters) { | ||
for (const key in event.multiValueQueryStringParameters) { | ||
const formattedKey = decodeURIComponent(key) | ||
query[formattedKey] = event.multiValueQueryStringParameters[key].map(value => decodeURIComponent(value)) | ||
} | ||
} else { | ||
for (const key in event.queryStringParameters) { | ||
const formattedKey = decodeURIComponent(key) | ||
query[formattedKey] = decodeURIComponent(event.queryStringParameters[key]) | ||
} | ||
} | ||
return url.format({ | ||
pathname: path.replace(replaceRegex, ''), | ||
query | ||
}) | ||
} | ||
const getRequestValuesFromAlbEvent = ({ event }) => { | ||
const values = getRequestValuesFromEvent({ | ||
event, | ||
path: getPathWithQueryStringUseUnescapeParams({ event }) | ||
}) | ||
return values | ||
} | ||
const getResponseToAlb = ({ | ||
@@ -5,0 +41,0 @@ statusCode, |
55704
1040