git ssb

0+

mixmix / ssb-client-basic-tutorial



Commit 6a6bdd02661ff78d984eb5b4df7130ae3ab01135

v00 - whoami

mixmix committed on 10/17/2018, 6:45:32 AM
Parent: 648a0593a2887cfceaa0915218fc802a29a5447f

Files changed

README.mdchanged
package.jsonchanged
index.jsdeleted
v00.jsadded
README.mdView
@@ -1,16 +1,13 @@
11 # SSB Client Basic
22
33 Let's build the most minimal client interface we can!
44
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`
67
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
109
11-## v0 - whoami
12-
1310 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!)
1411
1512 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.
1613
@@ -19,8 +16,4 @@
1916 `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.
2017
2118 We close the connection to the server using `server.close()` otherwise the connection stays open forever!
2219
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.jsonView
@@ -1,11 +1,9 @@
11 {
22 "name": "ssb-client-basic",
33 "version": "1.0.0",
44 "description": "",
5- "main": "index.js",
65 "scripts": {
7- "start": "node index.js",
86 "test": "standard --fix"
97 },
108 "repository": {
119 "type": "git",
index.jsView
@@ -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.jsView
@@ -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