lambda-router-adapter
Advanced tools
Comparing version 1.0.8 to 1.0.9
18
index.js
@@ -15,9 +15,15 @@ var request = require('./request'); | ||
*/ | ||
function newHandler(callback) { | ||
function newExpressHandler(app) { | ||
app.request.__proto__.__proto__ = request.LambdaHttpRequest.prototype; | ||
app.response.__proto__.__proto__ = response.LambdaHttpResponse.prototype; | ||
return function(event, context) { | ||
var req = request.convert(event); | ||
var res = response.newResponse(function(value) { | ||
context.done(null, response.convert(value)); | ||
var lambdaHttpRequest = request.convert(event); | ||
var lambdaHttpResponse = response.newResponse(function(lambdaHttpResponse) { | ||
context.done(null, response.convert(lambdaHttpResponse)); | ||
}); | ||
callback(req, res); | ||
app.handle(lambdaHttpRequest, lambdaHttpResponse, function(error) { | ||
if(error) { | ||
context.done(error); | ||
} | ||
}); | ||
} | ||
@@ -30,3 +36,3 @@ } | ||
newResponse: response.newResponse, | ||
newHandler: newHandler | ||
newExpressHandler: newExpressHandler | ||
} |
{ | ||
"name": "lambda-router-adapter", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Adapts Lambda Router Requests and Responses to NodeJS HTTP Request and Responses", | ||
@@ -22,3 +22,6 @@ "main": "index.js", | ||
"url": "^0.11.0" | ||
}, | ||
"devDependencies": { | ||
"express": "^4.13.3" | ||
} | ||
} |
@@ -7,2 +7,7 @@ 'use strict'; | ||
function LambdaSocket() { | ||
} | ||
LambdaSocket.prototype.destroy = function() {} | ||
/** | ||
@@ -28,4 +33,5 @@ * Converts a Lambda Event to a NodeJS Http Request. | ||
this.headers = lambdaRequest.headers; | ||
this.headers = lambdaRequest.headers || {}; | ||
this.body = lambdaRequest.body; | ||
this.socket = new LambdaSocket(); | ||
} | ||
@@ -42,2 +48,5 @@ | ||
module.exports.convert = convert; | ||
module.exports = { | ||
convert: convert, | ||
LambdaHttpRequest: LambdaHttpRequest | ||
} |
@@ -12,2 +12,3 @@ 'use strict'; | ||
* | ||
* @class | ||
* @param done | ||
@@ -59,4 +60,6 @@ * @constructor | ||
LambdaHttpResponse.prototype.end = function(data, encoding, callback) { | ||
LambdaHttpResponse.super_.prototype.end.apply(this, data, encoding, callback); | ||
this.done(this); | ||
LambdaHttpResponse.super_.prototype.end.apply(this, arguments); | ||
if(this.done) { | ||
this.done(this); | ||
} | ||
} | ||
@@ -63,0 +66,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17470
170
1