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

Move all platform-specific implementations into PlatformFunctions #1679

Merged
merged 11 commits into from
Feb 8, 2023

Conversation

anniel-stripe
Copy link
Contributor

@anniel-stripe anniel-stripe commented Feb 7, 2023

Summary

  1. Creates a createStripe and createWebhooks function that takes in platform functions as a parameter, removing the need for a global _platformFunctions field.
  2. Move all platform-dependent logic (including create...CryptoProvider and create...HttpClient into PlatformFunctions).
    a. l removed createHttpClient from Stripe and _createCryptoProvider from Webhook, since we can't have a "default" implementation as create...CryptoProvider and create...HttpClient take different types of arguments. The user will have to keep specifying httpClient on the stripe config and cryptoProvider in constructEvent/ constructEventAsync.

Testing

Added tests in PlatformFunctions.spec.ts and removed no-op tests from stripe.spec.ts. Also ran manual end-to-end tests in a Cloudflare Pages Functions and Cloudflare Worker project.

@anniel-stripe anniel-stripe force-pushed the anniel-platform-functions-refactor branch from a52996c to ef4162c Compare February 7, 2023 20:35
src/Webhooks.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@pakrym-stripe pakrym-stripe left a comment

Choose a reason for hiding this comment

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

Mostly nits + let's try and make the library work without customers providing extra parameters.

Copy link
Contributor

@pakrym-stripe pakrym-stripe left a comment

Choose a reason for hiding this comment

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

...

…ssertion, more specific return type on createStripe
@anniel-stripe anniel-stripe force-pushed the anniel-platform-functions-refactor branch from 81c80d5 to 45d9d1d Compare February 7, 2023 23:15
Copy link
Contributor

@pakrym-stripe pakrym-stripe left a comment

Choose a reason for hiding this comment

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

nits

Copy link
Contributor

@pakrym-stripe pakrym-stripe left a comment

Choose a reason for hiding this comment

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

Nice work!

@anniel-stripe anniel-stripe merged commit c412132 into master Feb 8, 2023
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.

2 participants