Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws-serverless-express

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-serverless-express - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

52

index.js

@@ -29,13 +29,16 @@ /*

function mapApiGatewayEventToHttpRequest(event, context, socketPath) {
event.headers['x-apigateway-event'] = JSON.stringify(event)
event.headers['x-apigateway-context'] = JSON.stringify(context)
const headers = event.headers || {}
headers['x-apigateway-event'] = JSON.stringify(event)
headers['x-apigateway-context'] = JSON.stringify(context)
return {
method: event.httpMethod,
path: getPathWithQueryStringParams(event),
headers: event.headers,
socketPath: socketPath,
// protocol: `${event.headers['X-Forwarded-Proto']}:`,
// host: event.headers.Host,
// hostname: event.headers.Host, // Alias for host
// port: event.headers['X-Forwarded-Port']
headers,
socketPath
// protocol: `${headers['X-Forwarded-Proto']}:`,
// host: headers.Host,
// hostname: headers.Host, // Alias for host
// port: headers['X-Forwarded-Port']
}

@@ -64,3 +67,3 @@ }

function forwardConnectionErrorResponseToApiGateway(server, error, context) {
// if debug: console.log(error)
console.error(error)
const errorResponse = {

@@ -75,2 +78,13 @@ statusCode: 502, // "DNS resolution, TCP level errors, or actual HTTP parse errors" - https://nodejs.org/api/http.html#http_http_request_options_callback

function forwardLibraryErrorResponseToApiGateway(server, error, context) {
console.error(error)
const errorResponse = {
statusCode: 500,
body: '',
headers: {}
}
context.succeed(errorResponse)
}
function forwardRequestToNodeServer(server, event, context) {

@@ -120,8 +134,18 @@ const requestOptions = mapApiGatewayEventToHttpRequest(event, context, getSocketPath(server._socketPathSuffix))

exports.proxy = (server, event, context) => {
if (server._isListening) {
forwardRequestToNodeServer(server, event, context)
} else {
startServer(server)
.on('listening', () => forwardRequestToNodeServer(server, event, context))
try {
if (server._isListening) {
forwardRequestToNodeServer(server, event, context)
} else {
startServer(server)
.on('listening', () => {
try {
forwardRequestToNodeServer(server, event, context)
} catch(error) {
forwardLibraryErrorResponseToApiGateway(server, error, context)
}
})
}
} catch (error) {
forwardLibraryErrorResponseToApiGateway(server, error, context)
}
}
{
"name": "aws-serverless-express",
"version": "1.1.3",
"version": "1.1.4",
"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": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc