stripe-samples / stripe-node-cloudflare-worker-template

Use stripe-node in a Cloudflare Worker.
MIT License
77 stars 16 forks source link

fix: update for wrangler 2 #3

Closed Cherry closed 1 year ago

Cherry commented 1 year ago

This repository currently uses wrangler 1 which is deprecated, and adds additional unneeded complexity with a separate build step.

Wrangler 2 can handle the polyfills for us now with node_compat, and the build is all handled natively in wrangler 2 without the need for a custom webpack config.

As a side note, I wrote a post about some of this on my blog. It might be worth showing an example to validate webhooks within Cloudflare Workers.

Cherry commented 1 year ago

Thanks for the contribution! This looks good to me aside from the comment about initializing stripe.

Thanks, addressed this in review! With Module Workers, this change is necessary. In real-world apps, we often create a re-usable useStripe or similar function that we pass env into for easy reusability, but I didn't want to over-complicate this example.