Skip to content

Commit 56e516a

Browse files
Version Packages (#76)
* Version Packages * Spelling * Changelog formatting * Fix prettier Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Daniel Abdelsamed <[email protected]>
1 parent 5669d23 commit 56e516a

File tree

4 files changed

+61
-57
lines changed

4 files changed

+61
-57
lines changed

.changeset/chilled-teachers-bathe.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,64 @@
11
# @as-integrations/aws-lambda
22

3+
## 2.0.0
4+
5+
### Major Changes
6+
7+
- [#67](https://github.com/apollo-server-integrations/apollo-server-integration-aws-lambda/pull/67) [`5669d23`](https://github.com/apollo-server-integrations/apollo-server-integration-aws-lambda/commit/5669d237acd426fcb790ea11b1ba6632a6ea28f2) Thanks [@BlenderDude](https://github.com/BlenderDude)! -
8+
9+
## Why Change?
10+
11+
In the interest of supporting more event types and allowing user-extensibility, the event parsing has been re-architected. The goal with v2.0 is to allow customizability at each step in the event pipeline, leading to a higher level of Lambda event coverage (including 100% custom event requests).
12+
13+
## What changed?
14+
15+
The second parameter introduces a handler that controls parsing and output generation based on the event type you are consuming. We support 3 event types out-of-the-box: APIGatewayProxyV1/V2 and ALB. Additionally, there is a function for creating your own event parsers in case the pre-defined ones are not sufficient.
16+
17+
This update also introduces middleware, a great way to modify the request on the way in or update the result on the way out.
18+
19+
```typescript
20+
startServerAndCreateLambdaHandler(
21+
server,
22+
handlers.createAPIGatewayProxyEventV2RequestHandler(),
23+
{
24+
middleware: [
25+
async (event) => {
26+
// event updates here
27+
return async (result) => {
28+
// result updates here
29+
};
30+
},
31+
],
32+
},
33+
);
34+
```
35+
36+
## Upgrade Path
37+
38+
The upgrade from v1.x to v2.0.0 is quite simple, just update your `startServerAndCreateLambdaHandler` with the new request handler parameter. Example:
39+
40+
```typescript
41+
import {
42+
startServerAndCreateLambdaHandler,
43+
handlers,
44+
} from '@as-integrations/aws-lambda';
45+
46+
export default startServerAndCreateLambdaHandler(
47+
server,
48+
handlers.createAPIGatewayProxyEventV2RequestHandler(),
49+
);
50+
```
51+
52+
The 3 event handlers provided by the package are:
53+
54+
- `createAPIGatewayProxyEventV2RequestHandler()`
55+
- `createALBEventRequestHandler()`
56+
- `createAPIGatewayProxyEventRequestHandler()`
57+
58+
Each of these have an optional type parameter which you can use to extend the base event. This is useful if you are using Lambda functions with custom authorizers and need additional context in your events.
59+
60+
Creating your own event parsers is now possible with `handlers.createRequestHandler()`. Creation of custom handlers is documented in the README.
61+
362
## 1.2.1
463

564
### Patch Changes

cspell-dict.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ changesets
55
cimg
66
circleci
77
codesandbox
8+
customizability
89
direnv
910
testsuite
1011
unawaited

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@as-integrations/aws-lambda",
33
"description": "An Apollo Server integration for hosting on AWS Lambda",
4-
"version": "1.2.1",
4+
"version": "2.0.0",
55
"author": "Michael Watson & Daniel Abdelsamed",
66
"license": "MIT",
77
"repository": {

0 commit comments

Comments
 (0)