Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AWS Lambda handlers #404

Merged
merged 7 commits into from
Feb 10, 2025
Merged

Add AWS Lambda handlers #404

merged 7 commits into from
Feb 10, 2025

Conversation

witoszekdev
Copy link
Member

@witoszekdev witoszekdev commented Feb 5, 2025

This PR adds handlers for AWS Lambda platform for events originating from HTTP events (e.g. Lambda URL, API Gateway).

Example implementation using this PR: https://github.com/witoszekdev/saleor-app-lambda-template

Copy link

changeset-bot bot commented Feb 5, 2025

🦋 Changeset detected

Latest commit: 8787d92

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

This PR includes changesets to release 1 package
Name Type
@saleor/app-sdk Patch

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

codecov bot commented Feb 5, 2025

Codecov Report

Attention: Patch coverage is 91.58879% with 18 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@4fa8271). Learn more about missing BASE report.
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...aws-lambda/saleor-webhooks/saleor-async-webhook.ts 8.33% 11 Missing ⚠️
src/handlers/platforms/aws-lambda/index.ts 0.00% 5 Missing and 1 partial ⚠️
.../handlers/platforms/aws-lambda/platform-adapter.ts 98.07% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #404   +/-   ##
=======================================
  Coverage        ?   82.64%           
=======================================
  Files           ?       95           
  Lines           ?     3497           
  Branches        ?      587           
=======================================
  Hits            ?     2890           
  Misses          ?      600           
  Partials        ?        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@witoszekdev witoszekdev changed the base branch from main to add-web-api-platform-handlers February 5, 2025 16:07
@witoszekdev witoszekdev force-pushed the add-aws-lambda-platform-handlers branch from 37d7948 to 3fb73af Compare February 5, 2025 16:12
@witoszekdev witoszekdev changed the base branch from add-web-api-platform-handlers to main February 5, 2025 16:16
Add exports

Update JSDocs

Add tests for register handler

Remove `saleorDomain` from type

Rename aws-lambda file

Throw errors in adapters, instead of resolving to null

Add AWS lambda tests

Fix lambda types

Fix lambda headers

Add lambda manifest test, fix headers resolution

Fetch API: add tests for protected handler, fix types

Add tests for lambda protected handler, fix types

Simplify Fetch API adapter logic, add tests for adapter

Add lambda tests

Refactor sync webhook names, refactor types

Add web api sync webhook tests

Add async webhook tests

Add lambda sync webhook test

Fix types

Removed unused functions

Remove fetch-api
Copy link
Contributor

github-actions bot commented Feb 6, 2025

Released snapshot build with @dev tag in npm with version: 0.0.0-pr-20250206120033.

Install it with:

pnpm add @saleor/app-sdk@0.0.0-pr-20250206120033

Copy link
Contributor

github-actions bot commented Feb 6, 2025

Released snapshot build with @dev tag in npm with version: 0.0.0-pr-20250206135700.

Install it with:

pnpm add @saleor/app-sdk@0.0.0-pr-20250206135700

Copy link
Contributor

github-actions bot commented Feb 7, 2025

Released snapshot build with @dev tag in npm with version: 0.0.0-pr-20250207113756.

Install it with:

pnpm add @saleor/app-sdk@0.0.0-pr-20250207113756

@witoszekdev witoszekdev marked this pull request as ready for review February 7, 2025 15:51
@witoszekdev witoszekdev requested a review from a team as a code owner February 7, 2025 15:51
return null;
}

return JSON.parse(this.request.body);
Copy link
Member

Choose a reason for hiding this comment

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

question: Is it save to run JSON.parse without proper error handling in case this.request.body will has invalid json?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we want it to throw error so that we know that request was invalid because of malformated JSON, not that the request was empty (if we would return null).

Ideally I would use neverthrow so that we don't throw exceptions, but I didn't want to introduce another dependency ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

In places we use getBody we have try...catch

@witoszekdev witoszekdev merged commit 853abaa into main Feb 10, 2025
9 checks passed
@witoszekdev witoszekdev deleted the add-aws-lambda-platform-handlers branch February 10, 2025 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants