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

Network Strategies #487

Merged

Conversation

AndrewBastin
Copy link
Member

@AndrewBastin AndrewBastin commented Jan 14, 2020

This PR intends to introduce Network Strategies into Postwoman.

Network Strategies are basically functions which take in the Postwoman Store and the request config and returns a Promise for the response. It generalizes the network request making process and makes further introduction of features easier.

Currently, this PR introduces 2 Network Strategies

  • AxiosStrategy : Uses axios to send the request
  • ProxyStrategy : Uses the postwoman proxy feature to send the request through a proxy.

Currently, Network Strategies allow its consumers to not worry about whether proxy is enabled, the sendNetworkRequest (found in functions/network.js) function will detect the appropriate strategy from the available and executes that. But in the future, when we plan to add new strategies (for e.g for native), we do not need to worry about rewriting the consumers to adopt those.

@AndrewBastin AndrewBastin added feature New feature or request core Changes regarding core concepts refactor Code refactoring labels Jan 14, 2020
@AndrewBastin AndrewBastin added this to the v2.0 milestone Jan 14, 2020
@AndrewBastin AndrewBastin self-assigned this Jan 14, 2020
@ghost
Copy link

ghost commented Jan 14, 2020

DeepCode's analysis on #061f86 found:

  • 0 critical issues. ⚠️ 0 warnings and 0 minor issues. ✔️ 0 issues were fixed.

💬 This comment has been generated by the DeepCode bot, installed by the owner of the repository. The DeepCode bot protects your repository by detecting and commenting on security vulnerabilities or other critical issues.


☺️ If you want to provide feedback on our bot, here is how to contact us.

@TravisBuddy
Copy link

Hey @AndrewBastin,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 74ebcac0-368d-11ea-b1be-0700b914e46e

@liyasthomas
Copy link
Member

Axios progress bar seems to be broken.

To reproduce:

  1. Visit deploy preview: https://deploy-preview-487--postwoman.netlify.com/
  2. Send a request
  3. Progress won't finish even after axios fetch response.

Except this, I couldn't find any bugs.

liyasthomas
liyasthomas previously approved these changes Jan 14, 2020
Copy link
Member

@liyasthomas liyasthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@AndrewBastin
Copy link
Member Author

Well, the AxiosStrategy doesn't use the $axios plugin thingy. Does the progress bar depend on that or something ? If so, we will need to fix that.

@liyasthomas
Copy link
Member

liyasthomas commented Jan 14, 2020

Well axios automatically bind it's progress to Nuxt's progress bar. We can turn that off, and invoke progress manually. Lemme find a fix for that.

Copy link
Member

@jamesgeorge007 jamesgeorge007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of comments.

functions/network.js Outdated Show resolved Hide resolved
functions/strategies/ProxyStrategy.js Outdated Show resolved Hide resolved
functions/strategies/ProxyStrategy.js Outdated Show resolved Hide resolved
@TravisBuddy
Copy link

Hey @AndrewBastin,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 5072dcd0-36ef-11ea-a8cf-c90382c1967d

jamesgeorge007
jamesgeorge007 previously approved these changes Jan 14, 2020
Copy link
Member

@jamesgeorge007 jamesgeorge007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

liyasthomas
liyasthomas previously approved these changes Jan 15, 2020
@AndrewBastin
Copy link
Member Author

@liyasthomas what about the progress bar issue ?

@liyasthomas
Copy link
Member

Fix coming in few mins

@AndrewBastin AndrewBastin merged commit c8878ab into hoppscotch:master Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Changes regarding core concepts feature New feature or request refactor Code refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants