-
Notifications
You must be signed in to change notification settings - Fork 299
Conversation
package.json
Outdated
@@ -65,6 +69,7 @@ | |||
"multicodec": "~0.5.1", | |||
"multihashes": "~0.4.14", | |||
"ndjson": "github:hugomrdias/ndjson#feat/readable-stream3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are shipping a non versioned module to users? If ndjson is not interested in the contribution, please create a fork and maintain it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this needs to get resolved. I think it's not so much the PR is not welcome it's more time commitment. Max added me to concat-stream
, perhaps I can also get admin here as well ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall seems good to me, left some questions.
This looks pretty awesome from a quick review on my phone 🥳 I would just like to suggest using https://github.com/sindresorhus/ky with ky-universal to remove the fetch helpers. I have been using this one for a while and it's a pretty good little wrapper around fetch and it's from sindre 💪. |
531f9ac
to
d84716a
Compare
The other part where I thought it might be helpful is with the querystring, but we'd still need a helper like Also, it's convenient to be able to specify repeated parameters as an array, e.g. Unless I'm missing something I think these are the only two helpers that Last thing worth mentioning is that in this PR, |
you can do whatever you need with https://github.com/sindresorhus/ky#hooks and if we create (https://github.com/sindresorhus/ky#kycreatedefaultoptions) a pre-configured instance with the options we need to use everywhere we only need one file for the http client. Right now we have four to support browser and node, ky-universal does that for us for free. also
i don't know if i understand this
Again it may be convenient but it's not spec compliant
i think @Gozala just wanted to use fetch instead of node's http, but we can still allow for custom http clients, Also |
I don't understand what do we have 4 of? How would
That's because our HTTP API sometimes returns text not JSON. We still need to extract the
This is about converting options to query string values. If we're given an options object and want to extract a value from it but the user doesn't set it we would end up with a querystring like e.g. const options = {}
const qs = new URLSearchParams({ x: options.x })
console.log(qs.toString()) // ?x=undefined We need to extract/convert querystring parameters from options objects because often they are kebab case in query string but camel case in JS to be idiomatic.
We'd still need to do what we're doing in
Repeated querystring parameters is spec compliant. I'm talking about internally converting options to query string params. It's way less boilerplate to use array syntax for repeated values. This wouldn't be exposed to the user in any way.
I'm still not sold on the reason why we have to take this hit!
I don't understand -
No I meant
Okay. Hopefully that'll be merged soon!
We don't have custom query string handling, but our API uses repeated parameters. I think request retries and timeout support are good reasons to use |
We have fetch.js, configure.js, configure.browser.js, querystring.js and querystring.browser.js i think we can get way with just one if we setup a Even without using ky we can merge querystring.js and querystring.browser.js because node supports If we need to have different default configs we can use https://github.com/ipfs/js-ipfs-utils/blob/master/src/env.js to conditional setup options without having two files to support browser and node.
humm and the api doesn't set the proper content-type headers ? or it returns as text but its actually a json string ?
yeah for me this is the most important part about using
and if we look at the code the majority of those 2.4kB is actually these features. everything else in the above comments is only about "can we do the same in a simple manner using |
My 2 cents (without reading through the whole thread) would be try to optimize (ergonomics) for standard web APIs, so that |
@hugomrdias another review please 🙏 |
This looks very good!! |
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
743cacd
to
6b293cd
Compare
This PR enabled pubsub in the browser and paves the way for a switch to using
fetch
by default and allowing for cancelable requests via the use ofAbortController
.It's mostly the work done in ipfs-shipyard/js-ipfs-http-client-lite#1 but adapted a bit for use here.
If approved, we can start work moving the other commands to use
fetch
. The work in https://github.com/ipfs-shipyard/js-ipfs-http-client-lite has proven the hard parts (uploading files) are all possible using thefetch
API.Since
fetch
is promise based, when moving the other commands it makes sense to just switch to async/await as per ipfs/js-ipfs#1670 (and callbackify instead of promisify).Depends on:
resolves #518
refs ipfs/js-ipfs#2093
resolves #932