lambda-request-handler
Advanced tools
Comparing version 0.2.0-beta.1 to 0.2.0-beta.2
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const setCookieVariations_1 = __importDefault(require("./setCookieVariations")); | ||
const fixResponseHeaders = (headers, supportMultiHeaders) => { | ||
@@ -9,4 +13,11 @@ const multiValueHeaders = {}; | ||
const values = headers[k]; | ||
singleValueHeaders[k] = values[values.length - 1]; | ||
multiValueHeaders[k] = values; | ||
if (k === 'set-cookie') { | ||
values.forEach((value, i) => { | ||
singleValueHeaders[setCookieVariations_1.default[i]] = value; | ||
}); | ||
} | ||
else { | ||
singleValueHeaders[k] = values.join(','); | ||
} | ||
} | ||
@@ -13,0 +24,0 @@ else { |
@@ -20,10 +20,13 @@ "use strict"; | ||
.then(app => { | ||
const reqOptions = eventToRequestOptions_1.default(event); | ||
const appHandler = in_process_request_1.default(app); | ||
return appHandler(reqOptions); | ||
}) | ||
.then(res => response_1.inProcessResponseToLambdaResponse(res, eventWithMultiValueHeaders(event))) | ||
.catch(e => { | ||
console.error(e); | ||
return response_1.errorResponse(); | ||
return Promise.resolve() | ||
.then(() => { | ||
const reqOptions = eventToRequestOptions_1.default(event); | ||
const appHandler = in_process_request_1.default(app); | ||
return appHandler(reqOptions); | ||
}) | ||
.then(res => response_1.inProcessResponseToLambdaResponse(res, eventWithMultiValueHeaders(event))) | ||
.catch(e => { | ||
console.error(e); | ||
return response_1.errorResponse(); | ||
}); | ||
}); | ||
@@ -30,0 +33,0 @@ }; |
{ | ||
"name": "lambda-request-handler", | ||
"version": "0.2.0-beta.1", | ||
"version": "0.2.0-beta.2", | ||
"license": "(MIT OR Apache-2.0)", | ||
@@ -8,3 +8,3 @@ "scripts": { | ||
"compile": "tsc", | ||
"test": "jest" | ||
"test": "jest --coverage" | ||
}, | ||
@@ -11,0 +11,0 @@ "files": [ |
20037
14
251