-
Notifications
You must be signed in to change notification settings - Fork 3
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
Provide HTTP (or WS) API to support browser extensions #7
Comments
Hi! If I understand correctly, this has nothing to do with "serving dat over HTTP" but is rather about "enabling an HTTP API on top of dat"? I wouldn't see why we could not add an http daemon on top of the current tcp one :). It should be fairly easy to reuse the code as the tcp one only has 50 lines. |
Yes, the goal is to be able to make a client that connects over HTTP which provides the browser with the same interface as the dat JS API. Would a PR using websockets be welcome? |
Okay I get it. Do you think that we can force end-users (ie API consumers) to use protocol-buffers instead of JSON? I mean currently the tcp daemon does:
And this code can remain unchanged by using WebSockets and slightly modified for HTTP by using Then, last point before getting in the code is to choose to do:
WDYT? |
Since this library already has the protobuf serialization / deserialization logic in JS, I think it would be very easy to publish that as an NPM package so that both the daemon and potential client implementations can rely on it.
I think that just having websockets will be enough to support any environments that can use HTTP.
Personally, I think having a single daemon that allows you to configure protocols would be ideal. Alternately, why not get rid of TCP and just have WS? It behaves very similarly with the added benefit of working in browsers. |
Yes why not just use WS it'd allow every sort of use case (cli, desktop, browser stuff etc.).
I want to keep the If you want to propose a patch, feel free to do so! |
Oh I almost forgot, we need to expose |
I'd suggest publishing a new module called Will the cli need to be changed to support WS? I could do PRs, but I'll have to wait until this weekend to be able to do a proper job with tests since I'm kinda busy during the week. :D |
Np then I'll do it!
A bit but not much in fact.
Why not but it's easier to maintain here especially since the daemon is in its early states :p. |
True, I think it'll be safe to just have module authors require the proto.js file directly from this project for now. Really excited for this! I've been crazy about IPFS the past while because they had pubsub and first class browser support, but the more I think about it the more I appreciate how Dat has a few but very powerful features instead of being super low level. |
Mhh one more though, because websockets would need a new dependency, I'll:
I'm not sure if HTTP has any added value but we can still add it later! |
Fair enough. How will people enable websockets? Will it be a configuration change and a global install of |
Mhh I don't like global modules... I'm thinking about a |
Yeah, that's pretty elegant. |
As per dat-ecosystem-archive/dat-desktop#518
The IPFS daemon provides an HTTP API which has enabled them to build a Chrome/Firefox extension, ipfs-companion, which allows users to view
ipfs://
urls directly in their preferred browser and provides awindow.ipfs
global to allow web apps to access the local IPFS node instead of bootstrapping one within the browser.Having an HTTP API for dat will allow us to do the same thing with the goal of providing the features in the beaker browser as an extension one can add to Chrome or Firefox (redirectng dat urls, DatArchive API).
The text was updated successfully, but these errors were encountered: