Skip to content

Commit

Permalink
Improve lambda docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hansott committed Feb 16, 2024
1 parent ad2626d commit 88e68b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
5 changes: 2 additions & 3 deletions docs/lambda.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const dependency = require("dependency");

preventPrototypePollution(); // <-- Call this after your main imports

exports.handler = protect(async (event, context) => {
exports.handler = protect(async (event, context) => { // <-- Wrap your handler with protect
// ...
});
```
Expand All @@ -27,8 +27,7 @@ import { lambda, preventPrototypePollution } from '@aikidosec/guard';
In order for the guard to work properly, we need the following event properties to be present:

* `event.body`
* `event.httpMethod` (optional)
* `event.headers` (optional)
* `event.headers`

That's it! Your AWS Lambda function is now protected by Aikido guard.

Expand Down
7 changes: 1 addition & 6 deletions library/src/sources/Lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,7 @@ function isJsonContentType(contentType: string) {
}

function isProxyEvent(event: unknown): event is APIGatewayProxyEvent {
return (
isPlainObject(event) &&
"httpMethod" in event &&
"requestContext" in event &&
"headers" in event
);
return isPlainObject(event) && "httpMethod" in event && "headers" in event;
}

export function createLambdaWrapper<
Expand Down

0 comments on commit 88e68b1

Please sign in to comment.