-
Notifications
You must be signed in to change notification settings - Fork 753
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
Added typescript webhook example #764
Added typescript webhook example #764
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.
Nice, I think moving this next to the non-TS version was the right call
|
||
const app: express.Application = express(); | ||
|
||
// Only use the raw body parser for webhooks. |
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.
I think we should remove this block, it implies that you need it, but I think you don't – the bodyParser.raw
call is enough (worth double-checking, I'm not 100% sure
)
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.
I think this was specifically to showcase that for all other routes we want to use the json parser. See Paul's original comment on that: #749 (comment)
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.
Yeah... if we did this:
app.use(bodyParser.json());
app.post(
'/webhook',
bodyParser.raw({type: 'application/json'}),
(req: express.Request, res: express.Response): void => {
would the app still work?
cc @adreyfus-stripe maybe you know?
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! Thanks @thorsten-stripe and @paulasjes-stripe !
Closes #749
r? @rattrayalex-stripe
In Paul's absence, I'm looking to finish up the TypeScript webhook sample.