Commit 92f5724222307187f23d545ec3c17c9aeedd6922
basic README + api improvement
mix irving committed on 1/31/2018, 3:18:33 AMParent: ceb725feeb3aac110f9c519878705290803c3ce7
Files changed
index.js | changed |
package.json | changed |
README.md | added |
index.js | ||
---|---|---|
@@ -4,9 +4,9 @@ | ||
4 | 4 … | |
5 | 5 … | const FLUME_VIEW_VERSION = 1.3 |
6 | 6 … | |
7 | 7 … | module.exports = { |
8 | - name: 'channels', | |
8 … | + name: 'channel', | |
9 | 9 … | version: require('./package.json').version, |
10 | 10 … | manifest: { |
11 | 11 … | get: 'async', |
12 | 12 … | stream: 'source', |
@@ -14,14 +14,15 @@ | ||
14 | 14 … | init: (server, config) => { |
15 | 15 … | console.log('///// CHANNELS plugin loaded /////') |
16 | 16 … | |
17 | 17 … | const view = server._flumeUse( |
18 | - 'channels', | |
18 … | + 'channel', | |
19 | 19 … | FlumeView(FLUME_VIEW_VERSION, reduce, map, null, initialState()) |
20 | 20 … | ) |
21 | 21 … | |
22 | 22 … | return { |
23 | 23 … | get: view.get, |
24 … | + subscription: view.get, | |
24 | 25 … | stream: view.stream, |
25 | 26 … | } |
26 | 27 … | } |
27 | 28 … | } |
package.json | ||
---|---|---|
@@ -1,15 +1,16 @@ | ||
1 | 1 … | { |
2 | 2 … | "name": "ssb-server-channels", |
3 | 3 … | "version": "1.0.0", |
4 | - "description": "", | |
4 … | + "repository": "git@github.com:ssbc/ssb-server-channel.git", | |
5 … | + "description": "A scuttlebot flumeview for all your channel related questions", | |
5 | 6 … | "main": "index.js", |
6 | 7 … | "scripts": { |
7 | 8 … | "test": "echo \"Error: no test specified\" && exit 1" |
8 | 9 … | }, |
9 | - "keywords": [], | |
10 | - "author": "", | |
11 | - "license": "ISC", | |
10 … | + "keywords": ["scuttlebutt", "flumeview"], | |
11 … | + "author": "mixmix", | |
12 … | + "license": "AGPL-3.0", | |
12 | 13 … | "dependencies": { |
13 | 14 … | "flumeview-reduce": "^1.3.12", |
14 | 15 … | "lodash": "^4.17.4" |
15 | 16 … | } |
README.md | ||
---|---|---|
@@ -1,0 +1,68 @@ | ||
1 … | +# ssb-server-channel | |
2 … | + | |
3 … | +## Usage | |
4 … | + | |
5 … | +```js | |
6 … | +const Server = require('scuttlebot') | |
7 … | +const config = { ... } // needs options | |
8 … | + | |
9 … | +// Install the plugin | |
10 … | +Server | |
11 … | + .use(require('scuttlebot/plugins/master')) // required | |
12 … | + .use(require('ssb-server-channel')) | |
13 … | + .use(require('ssb-backlinks')) // not required, just an example | |
14 … | + | |
15 … | +// Start the server | |
16 … | +const server = Server(config) | |
17 … | +``` | |
18 … | + | |
19 … | +## API | |
20 … | + | |
21 … | +### server.channel.subscriptions(cb) | |
22 … | + | |
23 … | +Get the channels and who is subscribed where `cb(err, data)` is called with `data` of form: | |
24 … | + | |
25 … | +```js | |
26 … | +{ | |
27 … | + [ChannelName]: Set // set of FeedIds of users subscribed to that channel | |
28 … | +} | |
29 … | +``` | |
30 … | + | |
31 … | +e.g | |
32 … | + | |
33 … | +```js | |
34 … | +{ | |
35 … | + 'ssb-learning': Set { '@gaQw6z...', '@ye+QM09...' }, | |
36 … | + 'brazil': Set { '@gaQw6z...' } | |
37 … | +} | |
38 … | +``` | |
39 … | + | |
40 … | +Check your [Set methods **on MDN**](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) | |
41 … | + | |
42 … | +And if you really need an Array : | |
43 … | + | |
44 … | +```js | |
45 … | +const s = new Set () | |
46 … | +set.add('mixmix') | |
47 … | +set.add('soapdog') | |
48 … | + | |
49 … | +[...s] // => ['mixmix', 'soapdog'] | |
50 … | +Array.from(s) // => ['mixmix', 'soapdog'] | |
51 … | +``` | |
52 … | + | |
53 … | + | |
54 … | +### server.channel.get(cb) | |
55 … | + | |
56 … | +Get the current state of the channel view. This will wait until the view is up to date, if necessary. | |
57 … | + | |
58 … | +`cb(err, data)` is a standard callback function where `data` is of the form: | |
59 … | + | |
60 … | +```js | |
61 … | +{ | |
62 … | + [ChannelName]: Set // set of FeedIds of users subscribed to that channel | |
63 … | +} | |
64 … | +``` | |
65 … | + | |
66 … | +### server.channel.get(cb) | |
67 … | + | |
68 … | + |
Built with git-ssb-web