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

unable to define a proxy #34

Open
thenano opened this issue Jul 15, 2016 · 4 comments
Open

unable to define a proxy #34

thenano opened this issue Jul 15, 2016 · 4 comments

Comments

@thenano
Copy link

thenano commented Jul 15, 2016

I would like to push events and listen to event streams from a server inside a corporate proxy. From what I can gather from the code, there's no current way to define proxy settings for the requests the lib is doing to the particle cloud api.

It seems like for normal functions within the Particle module, superagent-proxy (https://github.com/TooTallNate/superagent-proxy) and a configurable flag could solve it, since it uses superagent for the requests.
For EventStream it will be trickier since it uses default node http/https libraries. I've implemented the EventStream solution using request and setting the proxy there.

@monkbroc
Copy link
Member

I think your best bet is to look at the cloud API documentation https://docs.particle.io/reference/api/ and write code to access those HTTP endpoints through your proxy. It sounds like wrapping the particle-api-js module in a proxy module would be harder than wiring a couple HTTP calls from scratch.

@thenano
Copy link
Author

thenano commented Jul 18, 2016

Basically I have stopped using this library and am doing the HTTP calls myself. That being said, this library provides a nice DSL, and some good practices around error handling and handling streams, which I would have to re-implement, and which I would love to avoid. Also, I imagine this library will continue to evolve as the api evolves, and so having the ability to just update this and be compatible with latest api would be great.
If there's interest, I can try and work on a pull-request.

@monkbroc
Copy link
Member

Sure, if you'd like to investigate how to support proxies, go ahead. I'd love to see a pull request that adds the ability to inject additional superagent plugins, and puts information in the readme on how to add a proxy plugin.

@brycekahle
Copy link
Contributor

I would recommend avoiding request. We specifically switched away from it because it is too heavy for a library that needs to run in the browser.

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

No branches or pull requests

3 participants