-
Notifications
You must be signed in to change notification settings - Fork 78
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
feat(type-safe-api): add s3 integration #592
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for this!
I've added a few comments below :) Also please could you add some documentation here? Would be great to include some examples in the docs of how to read/write some simple json objects :)
This is a really great start! I can see this being a really useful addition to type-safe-api - thanks a bunch! 😄
Sure, I totally forgot the documentation, I'll update it too |
…construct bucket invocation URI
This pull request is now marked as stale because it hasn't seen activity for a while. Add a comment or it will be closed soon. If you wish to exclude this issue from being marked as stale, add the "backlog" label. |
Closing this pull request as it hasn't seen activity for a while. Please add a comment @mentioning a maintainer to reopen. If you wish to exclude this issue from being marked as stale, add the "backlog" label. |
@valebedu just wondered if you're still working on this? Would be an awesome addition but no worries if you don't have the time! :) |
Hi @cogwirrel, yes it's just a bit difficult to find time 😅 I'll try to work on it this weekend |
All good, no rush! :) Will keep this PR alive 😄 |
# Conflicts: # packages/type-safe-api/src/construct/spec/utils.ts
…All and custom strategies
…with default to catch all strat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much @valebedu! Just a few minor comments :) I think the main thing remaining if you don't mind is to make sure path parameters are mapped appropriately :)
packages/type-safe-api/src/construct/integrations/error-integration-response.ts
Outdated
Show resolved
Hide resolved
packages/type-safe-api/src/construct/integrations/error-integration-responses.ts
Outdated
Show resolved
Hide resolved
packages/type-safe-api/docs/developer_guides/type-safe-api/integrations.md
Outdated
Show resolved
Hide resolved
packages/type-safe-api/src/construct/integrations/error-integration-response.ts
Outdated
Show resolved
Hide resolved
When viewing your example in docs I was thinking about the fixed status code with a DELETE and 200 is sometimes not what user wants. So I added a prop to override it if needed |
…ful default error behaviour Refactor ErrorIntegrationResponse into IntegrationResponseSet, encompassing any response rather than just error responses, allowing users to fully customise the s3 integration behaviour if they wish. Updated default error response behaviour to extract the error message from the S3 xml response using VTL mapping templates for a more intuitive default experience.
Thanks for this! 😄 It made me start thinking that users may even wish to customise other parts of the default/successful response, so I decided to generify your I was also playing around with a test project using your branch - it's so awesome! Love how path parameters just work and I can change the path/method easily :) One slightly less intuitive thing I found was the default aws-pdk/packages/type-safe-api/src/project/model/smithy/smithy-definition.ts Lines 169 to 176 in 09335a2
Some kind of automatic coercion of the s3 xml error into the corresponding error response in the model would be the ideal way to handle it but I'd have thought that would be super complicated to build! As a compromise, I decided to make the default error behaviour |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thank you so much :) Yes, once you try S3 you find it really useful, I use it mostly in combinations with cron lambdas that run each several hours to get a specific result from a DB, writing it to a bucket an serving it through API Gateway, this is much cheaper and offers less pressure over DB for a result that doesn't change often. And yes handling all S3 errors could be quite difficult to do. Maybe if this integration became popular with developers we will improve it :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking really good, nice team work :)
packages/type-safe-api/src/construct/integrations/integration-response-set.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!!
As discussed here #539, this is a proposition to add an s3 integration to type-safe-api