Commit 6a6bdd02661ff78d984eb5b4df7130ae3ab01135
v00 - whoami
mixmix committed on 10/17/2018, 6:45:32 AMParent: 648a0593a2887cfceaa0915218fc802a29a5447f
Files changed
README.md | changed |
package.json | changed |
index.js | deleted |
v00.js | added |
README.md | ||
---|---|---|
@@ -1,16 +1,13 @@ | ||
1 | 1 … | # SSB Client Basic |
2 | 2 … | |
3 | 3 … | Let's build the most minimal client interface we can! |
4 | 4 … | |
5 | -If you'd like to revisit the snapshot of each step you can jump to each version using git! (I've made git tags). | |
5 … | +Get started by running `npm install` | |
6 … | +To run a particular file run e.g. `node v00.js` | |
6 | 7 … | |
7 | -- `git tag --list` to see all tags | |
8 | -- `git checkout TAGNAME` to jump to that point in time | |
9 | - - make sure you run `npm install` when you jump to make sure you have the right things installed for that particular snapshot of code | |
8 … | +## `v00` - whoami | |
10 | 9 … | |
11 | -## v0 - whoami | |
12 | - | |
13 | 10 … | We're not going to worry about running a 'server' locally (the backened peer/ db), we can rely on someone else to do that (just start up Patchwork or Patchbay and you're good to go!) |
14 | 11 … | |
15 | 12 … | Here we install [**ssb-client**](https://github.com/ssbc/ssb-client) which establishes a remote connection to the scuttlebot server being run by Patchworl/ Patchbay. |
16 | 13 … | |
@@ -19,8 +16,4 @@ | ||
19 | 16 … | `whoami` is an asynchronous method which calls back with the details of the feed your scuttlebot is currently running. It's the basic "hello world" of scuttlebutt. |
20 | 17 … | |
21 | 18 … | We close the connection to the server using `server.close()` otherwise the connection stays open forever! |
22 | 19 … | |
23 | -Running this code can be done from the terminal with the command: | |
24 | -- `node index.js` | |
25 | -- `npm start` or `npm run start` (which runs the command in the 'start' script in our package.json) | |
26 | - |
package.json | ||
---|---|---|
@@ -1,11 +1,9 @@ | ||
1 | 1 … | { |
2 | 2 … | "name": "ssb-client-basic", |
3 | 3 … | "version": "1.0.0", |
4 | 4 … | "description": "", |
5 | - "main": "index.js", | |
6 | 5 … | "scripts": { |
7 | - "start": "node index.js", | |
8 | 6 … | "test": "standard --fix" |
9 | 7 … | }, |
10 | 8 … | "repository": { |
11 | 9 … | "type": "git", |
index.js | ||
---|---|---|
@@ -1,18 +1,0 @@ | ||
1 | -const Connection = require('ssb-client') | |
2 | - | |
3 | -console.log('Connecting') | |
4 | - | |
5 | -Connection((err, server) => { | |
6 | - if (err) { | |
7 | - throw err | |
8 | - } | |
9 | - console.log('Connection established') | |
10 | - | |
11 | - server.whoami((err, keys) => { | |
12 | - if (err) console.log('could not get keys, got err', err) | |
13 | - else console.log('whoami details:', keys) | |
14 | - | |
15 | - console.log('disconnecting from server') | |
16 | - server.close() | |
17 | - }) | |
18 | -}) |
v00.js | ||
---|---|---|
@@ -1,0 +1,18 @@ | ||
1 … | +const Connection = require('ssb-client') | |
2 … | + | |
3 … | +console.log('Connecting') | |
4 … | + | |
5 … | +Connection((err, server) => { | |
6 … | + if (err) { | |
7 … | + throw err | |
8 … | + } | |
9 … | + console.log('Connection established') | |
10 … | + | |
11 … | + server.whoami((err, keys) => { | |
12 … | + if (err) console.log('could not get keys, got err', err) | |
13 … | + else console.log('whoami details:', keys) | |
14 … | + | |
15 … | + console.log('disconnecting from server') | |
16 … | + server.close() | |
17 … | + }) | |
18 … | +}) |
Built with git-ssb-web