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

Added typescript webhook example #764

Merged

Conversation

thorsten-stripe
Copy link
Contributor

Closes #749

r? @rattrayalex-stripe

In Paul's absence, I'm looking to finish up the TypeScript webhook sample.

Copy link
Contributor

@rattrayalex-stripe rattrayalex-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, I think moving this next to the non-TS version was the right call

r? @thorsten-stripe


const app: express.Application = express();

// Only use the raw body parser for webhooks.
Copy link
Contributor

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
)

Copy link
Contributor Author

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)

Copy link
Contributor

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?

examples/webhook-signing/README.md Outdated Show resolved Hide resolved
examples/webhook-signing/README.md Show resolved Hide resolved
Copy link
Contributor

@rattrayalex-stripe rattrayalex-stripe left a 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 !

@rattrayalex-stripe rattrayalex-stripe merged commit 8f3c3ec into stripe:master Jan 16, 2020
@thorsten-stripe thorsten-stripe deleted the thorsten/typescript-example branch January 22, 2020 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants