Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upadd api #496
Comments
juliangruber
added
question
labels
Jun 24, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
joehand
Jun 24, 2016
Member
+1 for having a library, and keeping it separate from the cli. While it's pretty straightforward to use hyperdrive and related modules to DIY Dat, it's not trivial.
Having a dedicated JS library will allow us to make a tested library that developers can use immediately. With a DIY Dat stuff, developers will have a bit more leg work and may have to add tests for dat-related code.
I've (kinda) already started this in the logger-module branch.
|
+1 for having a library, and keeping it separate from the cli. While it's pretty straightforward to use hyperdrive and related modules to DIY Dat, it's not trivial. Having a dedicated JS library will allow us to make a tested library that developers can use immediately. With a DIY Dat stuff, developers will have a bit more leg work and may have to add tests for dat-related code. I've (kinda) already started this in the logger-module branch. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lukeburns
Jun 24, 2016
+1
A minimal high-level library might look something like...
var api = require('dat-api')
var dat = api()
dat.share(path, function (err, key) {
if (!err) console.log('key', key)
})
dat.download(key, path, function (err) {
if (!err) console.log('saved to', path)
})
lukeburns
commented
Jun 24, 2016
|
+1 var api = require('dat-api')
var dat = api()
dat.share(path, function (err, key) {
if (!err) console.log('key', key)
})
dat.download(key, path, function (err) {
if (!err) console.log('saved to', path)
}) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
juliangruber
Jun 25, 2016
Collaborator
we can probably start with a 1:1 mapping of cli commands to js methods
|
we can probably start with a 1:1 mapping of cli commands to js methods |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
paging @mafintosh (who has relevant opinions) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mafintosh
Jun 25, 2016
Member
I've been arguing
There is a bunch of trade-offs / configuration involved in using the tool, and imo it's more sustainable to do a modular approach where we have a series of small modules that make out the "Dat framework".
Since Dat doesn't have a clear "one thing it does" it invites bike shedding agreeing on APIs and we'd be indirectly blessing some specific use cases. For example, booting docker containers over Dat, requires a very different approach than simple cloning a normal data. Writing a chat app of top of Dat has similar differences.
What I propose instead is a more radical massively modular approach where we publish a series of decoupled modules that allows you to compose a dat stack in ~20 lines of code. This forces us to decouple the stack as well. Whenever something is too complicated to do, make a module that makes it easier.
The hyperdrive-archive-swarm module is a great example of this as it reduced the complexity of setting up a network swarm to hyperdriveArchiveSwarm(archive). If adding a bunch of files is too complicated a similar approach would help make that easier.
For this approach to work we need to have very good documentation and examples that show how you compose different use cases and explains how everything fits together. It also hurts discoverability compared to having a Dat framework module.
|
I've been arguing There is a bunch of trade-offs / configuration involved in using the tool, and imo it's more sustainable to do a modular approach where we have a series of small modules that make out the "Dat framework". Since Dat doesn't have a clear "one thing it does" it invites bike shedding agreeing on APIs and we'd be indirectly blessing some specific use cases. For example, booting docker containers over Dat, requires a very different approach than simple cloning a normal data. Writing a chat app of top of Dat has similar differences. What I propose instead is a more radical massively modular approach where we publish a series of decoupled modules that allows you to compose a dat stack in ~20 lines of code. This forces us to decouple the stack as well. Whenever something is too complicated to do, make a module that makes it easier. The hyperdrive-archive-swarm module is a great example of this as it reduced the complexity of setting up a network swarm to For this approach to work we need to have very good documentation and examples that show how you compose different use cases and explains how everything fits together. It also hurts discoverability compared to having a Dat framework module. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
maxogden
Jun 25, 2016
Member
So if we decide that "Dat" is a very narrow subset of the possibility space that is the hyperdrive/hypercore/discovery-channel stack, then we can have the 'dat-api' module only do that one narrow subset.
On the other hand I agree with the quote above: "While it's pretty straightforward to use hyperdrive and related modules to DIY Dat, it's not trivial.".
I guess it comes down to: do we wanna push one use case and make that the flagship easy to use thing, or do we want to not commit to one use case, and make it more advanced to build your own framework.
IMO a good ecosystem has both, so I don't think they're mutually exclusive (see choo vs yo-yo vs bel for example)
|
So if we decide that "Dat" is a very narrow subset of the possibility space that is the hyperdrive/hypercore/discovery-channel stack, then we can have the 'dat-api' module only do that one narrow subset. On the other hand I agree with the quote above: "While it's pretty straightforward to use hyperdrive and related modules to DIY Dat, it's not trivial.". I guess it comes down to: do we wanna push one use case and make that the flagship easy to use thing, or do we want to not commit to one use case, and make it more advanced to build your own framework. IMO a good ecosystem has both, so I don't think they're mutually exclusive (see choo vs yo-yo vs bel for example) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
karissa
Jun 27, 2016
Collaborator
I'm fine with having a JS api, but if it exists it should expose only the same exact functions (and options) available in the cli.
|
I'm fine with having a JS api, but if it exists it should expose only the same exact functions (and options) available in the cli. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
maxogden
Jun 28, 2016
Member
good discussion everyone, if someone wants to pursue this sounds like they can start by experimenting with a separate dat-api module outside this repo
|
good discussion everyone, if someone wants to pursue this sounds like they can start by experimenting with a separate dat-api module outside this repo |
maxogden
closed this
Jun 28, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Started working on that here: https://github.com/joehand/dat-js. |
juliangruber commentedJun 24, 2016
spawned by discussion in #495, should we create a high level javascript api to the dat network?
I think +1, a module called
dat-apior something, separate from this repo, so