Coder Social home page Coder Social logo

balena-request's People

Contributors

balena-ci avatar emirotin avatar flowzone-app[bot] avatar josecoelho avatar jsreds avatar jviotti avatar klutchell avatar moranf avatar myarmolinsky avatar page- avatar pimterry avatar resin-io-modules-versionbot[bot] avatar thgreasi avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

balena-request's Issues

Fix proxy handling

It looks like recent releases of global-tunnel-ng don't actually handle proxies correctly, and at the very least the tests in this repo fail.

Resolve security warnings

We're getting security warnings about handlebars, marked and uglify. None of these should actually affect this package, but we should update them anyway to guarantee that, and get rid of the warnings here.

Abstract the fetch mockery code

Maybe we could just expose a method that says installMocks that would return a properly configured fetchMock instance as well as setup all the expected things.

Or just abstract the setup code to a single submodule and expose a method setFetch.

See this thread: balena-io-modules/balena-pine#25

Default to native `fetch` when available?

The ponyfill module always returns the version based on XHR [https://github.com/qubyte/fetch-ponyfill/issues/21] which IMO can be less performant. Though we know that Edge 14 has some issues with its fetch implementation [https://github.com/qubyte/fetch-ponyfill/issues/9#issuecomment-253911888]

So should we default to the global fetch or not?
Doing so would also simplify the mocking a lot, right? We could just set the mocked fetch as global and voila.

@pimterry discuss :)

`baseUrl` is actually the required param

Right now the refreshToken param defaults to true, and in that case the request to /whoami is sent. If the baseUrl is empty then it fails because fetch doesn't know what to do

I think the best thing to do is make the apiUrl an optional param to the request factory and use it for the /whoami request in the send method. If apiUrl is not passed and refreshToken is set err quickly and always (not only when the token is expired).

Additionally make the default refreshToken value an option to the factory.

Or at least specify in docs that the baseUrl is required and must be the API URL (which is kinda strange as other than that the module allows sending arbitrary requests to any hosts, but uses the baseUrl for the /whoami request.

The stream method doesn't handle the headers properly on Edge

Namely when using the resin-sdk's logs.subscribe() method on Edge the network panel shows a 401 on an HTTP/2 request

Name	Protocol	Method	Result	Content type	Received	Time	Initiator
https://api.resinstaging.io/device/v2/2876517021a5ca34f977f084132540ae/logs?count=0&stream=1	HTTP/2	GET	401	text/plain	12 B	383.15 ms	Fetch

Accept: */*
Accept-Encoding: gzip, deflate
Host: api.resinstaging.io
map: [object Object]
Origin: https://dashboard.resinstaging.io
Referer: https://dashboard.resinstaging.io/devices/2876517021a5ca34f977f084132540ae/summary
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393

See: https://github.com/resin-io/resin-ui/issues/2280

Outdated readme

The module scans your environment for a saved session token. Alternatively, you may pass the apiKey options. Otherwise, the request is made anonymously.

Should be replaced

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.