Using Stripe module in http.ts
I was successfully able to create an action which utilized the Stripe module.
However, when trying to set up my Stripe webhooks in http.ts, there seems to be an error with resolving the Stripe module. "use node" can't be added to to http.ts so I was wondering if there was a workaround for this issue.
I've tried several methods of creating the Stripe object, and have it working on NextAPI.
The error is shown below and here is the http.ts file: https://codepaste.xyz/posts/F8qvlItqlMHDANHPEhhJ
The slug can't be deployed to dev due to the error cause by the initialization "new Stripe(...)"

3 Replies
As a workaround, you can move the stripe portions into an action (where you can add
"use node"
) and invoke the action from your HTTP handler using runAction
(definitely kinda awkward, but hopefully works?)
I believe we're thinking about allowing httpAction
s defined in node and also continually trying to build out our own JS execution environment to allow more node modulesThat should work I'll give it a shot and keep you posted
Yep it'd definitely be convenient but having
actions
as the core place that complex logic resolves to is also an unexpectedly neat patternyeah, one benefit here is you can invoke an action multiple ways
so if you treat the http layer as just an adapter, you get good reusability out of the convex action being also invokable via a convex client, or a schedule, or any other forthcoming convex triggering mechanism
so keeping the http layer thin/adaptive and most of the business logic in an action is generally a good idea