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

Add support for http.IncomingMessage #6

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Add support for http.IncomingMessage #6

wants to merge 19 commits into from

Conversation

karpawich
Copy link

Resolves #5

@karpawich karpawich changed the title Add support for http.ClientRequest as the request object Add support for http.IncomingMessage as the request object Jun 6, 2020
@karpawich karpawich changed the title Add support for http.IncomingMessage as the request object Add support for http.IncomingMessage Jun 6, 2020
@gverni
Copy link
Owner

gverni commented Jun 13, 2020

Thanks @karpawich for the PR, but it's incomplete. IncomingMessage and ClientRequest don't have a body property. They are both streams, and you need to read them all to get the body of the request. Also, since Slack is using application/x-www-form-urlencoded encoded payload, you also need to parse the body once you received all the data.

It's a very good idea to add support for Node's http interface, so let me know if you want to add the handling of the request body to this PR.

index.js Outdated Show resolved Hide resolved
test/validate-slack-request.js Outdated Show resolved Hide resolved
@karpawich
Copy link
Author

karpawich commented Jun 16, 2020

I'm happy to add body parsing support!

I will make the following changes to this PR accordingly:

  • add body parsing support
  • create a separate test file for Express, Next.js, and http
  • update the README & other documentation to reflect changes

@karpawich karpawich requested a review from gverni June 16, 2020 21:29
@karpawich
Copy link
Author

karpawich commented Jun 16, 2020

@gverni The PR is ready for another review.

Since the validateSlackRequest function is now async, I believe that would mean a "MAJOR" version bump to 2.0.0 per Semantic Versioning because it introduces a breaking change to the API.

Let me know your thoughts. I am happy to make any final changes (including the version bump) that you request 👍

@karpawich
Copy link
Author

@gverni ^ bump, in case you missed my changes!

@gverni
Copy link
Owner

gverni commented Jul 13, 2020

Hey @karpawich thanks for the nudge, and sorry it took me so long. I'm going to be reviewing your PR in the next couple of days! Thanks for that

@gverni
Copy link
Owner

gverni commented Jul 31, 2020

Hey @karpawich thanks for the great work you did and sorry for the late feed-back. I like a lot the idea of supporting http and next.js but I'm a bit reluctant around changing it to an asynchronous module. How about adding an extra parameters for the body and have developers doing the parsing outside of this module. In that way we don't introduce any breaking change. We can use your code in getBodyFromStream() as reference in the documentation. How does that sound?

@karpawich
Copy link
Author

Unfortunately, I no longer have the time to make any further revisions to this PR while I focus on school.

@gverni or anyone else - if you'd like to make the final changes requested above, that'd be great! They shouldn't take too long.

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.

Incompatible with http.IncomingMessage
2 participants