Having spent the morning playing around with the APIs and trying to get an app going, I’ve extracted the API as it is in the latest demo app into its own package.
It’s been refactored to be promise based and I’ve simplified away the angular code there too.
Right now auth work and create file is returning true. I haven’t had chance to test the rest yet (that’s my first npm package, was a bit confused with publishing etc; so this will be buggy). But if you want to pull and play, and PR with solutions to any bugs, that would be most welcome.
Anyway, I plan to update this as I find the problems that will exist in there. But I thought it might be useful for other devs even as it is now.
If this is anything along the lines of making the APIs accessible for automating actions - especially from a command line, that is very welcome and timely!.. On my to do list still is getting a route to action that isn’t just the Demo App.
There are obviously nodejs examples at Introduction and I had limited success with those… half way up a learning curve there.
It’s pretty much just a wrapper lib for the readme functions, but up to date.
Purely extracted from the demo app.
You should be able to at least get the auth going with a small node.js script, for example. I have an app I’m using this in which I’ll be putting on github later, when it’s not a total mess. I need to implement this in there first.
But if you want to test the various endpoints, I’d recommend grabbing this extension which lets you easily formulate the requests with headers and relevant body parts. That’s what I’ve been using to check my requests etc.
Great stuff @joshuef I’ve also been using Promises in my pure JavaScript implementation (non-nodejs) of a remoteStorage back-end that uses the SAFE-NFS API so it might make sense to extract this as a wrapper at some point then we’ll have both node and pure JavaScript options. I still get confused by Promises though, so maybe not just yet
So like you I have to do more work before it will be much use for anyone to build on. Interim code like ours is though still helpful - I think just having some code to look at is useful as well (so I do push my remoteStorage backend to github from time to time - file safestore.js - though I have completely rewritten it since the last push!).
When I go back to playing with launcher I’ll be keen to take a look at what you created. I also implemented experimental stuff in that using Promises and I think MaidSafe should consider switching over (from callbacks) especially as Promises are now part of the JS browser standard. Note to @Krishna_Kumar! Maybe we can all build on your safe-js repo?
Yeh, ideally, you could use this instead of having to rewrite the API calls.
The isomorphic fetch is nicely done and makes it simple to doYourFunction().then( doSomethingElse ), so much nicer than the callback workflow (imo).
This is pretty basic representations of the API so far, so hopefully you would be able to incorporate it easily enough. If you need any help implementing this or any promise stuff, or suggestions / PRs for this, just drop me a message!