Skip to content

Conversation

@BlenderDude
Copy link
Member

Implements the ALB event type. Given that V2 is very similar to ALB, I rewrote some of the normalization logic to condense parsing. Let me know your thoughts on this; after some research, it seems like there is no "official AWS supported way" of knowing exactly what event type has been passed to the Lambda. Given that, I figure we shouldn't try to parse type, and just look for the properties we need within the event object.

I also redid some of the type naming. Renamed GatewayEvent to IncomingEvent to better encapsulate ALB and lambda at edge and CloudFront functions in the future. Marked as a minor change as GatewayEvent is removed.

@changeset-bot
Copy link

changeset-bot bot commented Oct 19, 2022

🦋 Changeset detected

Latest commit: 84028ee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@as-integrations/aws-lambda Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

@trevor-scheer trevor-scheer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with the one question that may or may not need to be addressed

src/index.ts Outdated
| APIGatewayProxyResult
| ALBResult
) & {
statusCode: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok to assume this? I don't actually know, but the types for APIGatewayProxyStructuredResultV2 include

statusCode?: number | undefined;

Are the types lying? (maybe we can submit a PR to correct them if so?)

Asserting type within the tests instead of the runtime leads to more exact runtime types without breaking the test
httpServer.addListener('request', createMockALBServer(handler));
httpServer.addListener(
'request',
createMockALBServer(handler as Handler<ALBEvent, ALBResult>),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I prefer this cast here instead of in the runtime, good change 👍

@BlenderDude BlenderDude merged commit 722539c into main Nov 22, 2022
@BlenderDude BlenderDude deleted the feature/accept-alb-event-type branch November 22, 2022 01:19
@github-actions github-actions bot mentioned this pull request Nov 22, 2022
@glasser
Copy link

glasser commented Jan 9, 2023

Looks like the README could be updated too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants