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

lambda-request-handler

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lambda-request-handler - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

4

dist/compile/eventToRequestOptions.d.ts

@@ -1,3 +0,3 @@

import { APIGatewayEvent } from './types';
declare const eventToRequestOptions: (event: APIGatewayEvent) => import("in-process-request/dist/compile/httpMock").MockRequestOptions;
import { APIGatewayEvent, LambdaContext } from './types';
declare const eventToRequestOptions: (event: APIGatewayEvent, ctx?: LambdaContext | undefined) => import("in-process-request/dist/compile/httpMock").MockRequestOptions;
export default eventToRequestOptions;

@@ -24,6 +24,10 @@ "use strict";

};
const eventToRequestOptions = (event) => {
const eventToRequestOptions = (event, ctx) => {
let remoteAddress = undefined;
let ssl = false;
const headers = getValuesFromStringAndMultiString(event.headers, event.multiValueHeaders);
if (ctx) {
headers['x-aws-lambda-request-id'] = ctx.awsRequestId;
}
const queryStringParams = getValuesFromStringAndMultiString(event.queryStringParameters, event.multiValueQueryStringParameters);
if (event.requestContext && event.requestContext.elb) {

@@ -43,2 +47,6 @@ //load balancer request - it has the client ip in x-forwarded-for header

}
//elb also doesn't uri decode query string params
Object.keys(queryStringParams).forEach(k => {
queryStringParams[k] = decodeURIComponent(queryStringParams[k]);
});
}

@@ -50,3 +58,2 @@ else {

}
const queryStringParams = getValuesFromStringAndMultiString(event.queryStringParameters, event.multiValueQueryStringParameters);
return {

@@ -53,0 +60,0 @@ method: event.httpMethod,

@@ -8,3 +8,4 @@ /// <reference types="node" />

type LambdaResponse = apigw.LambdaResponse;
type APIGatewayEventHandler = (event: handler.APIGatewayEvent) => Promise<handler.LambdaResponse>;
type LambdaContext = apigw.LambdaContext;
type APIGatewayEventHandler = (event: handler.APIGatewayEvent, context?: handler.LambdaContext) => Promise<handler.LambdaResponse>;
}

@@ -11,0 +12,0 @@ declare const handler: {

@@ -14,3 +14,3 @@ "use strict";

let _p = null;
return event => {
return (event, ctx) => {
if (!_p) {

@@ -23,3 +23,3 @@ _p = appPromiseFn();

.then(() => {
const reqOptions = eventToRequestOptions_1.default(event);
const reqOptions = eventToRequestOptions_1.default(event, ctx);
const appHandler = in_process_request_1.default(app);

@@ -26,0 +26,0 @@ return appHandler(reqOptions);

@@ -33,1 +33,4 @@ export interface StringMap<T> {

}
export interface LambdaContext {
awsRequestId: string;
}
{
"name": "lambda-request-handler",
"version": "0.2.0",
"version": "0.2.1",
"license": "(MIT OR Apache-2.0)",

@@ -5,0 +5,0 @@ "scripts": {

@@ -32,2 +32,5 @@ # lambda-request-handler

An additional header is injected into the request
* `x-aws-lambda-request-id` - AWS Lambda Request Id
```sh

@@ -46,2 +49,3 @@ $ npm install lambda-request-handler

id: req.params.id,
lambdaRequestId: req.header('x-aws-lambda-request-id')
name: 'John'

@@ -48,0 +52,0 @@ })

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