1 | # ssb-ws
|
2 |
|
3 | ssb-ws & http server for ssb.
|
4 |
|
5 | Work In Progress
|
6 |
|
7 | ``` js
|
8 | sbot plugins.install ssb-ws
|
9 | ```
|
10 |
|
11 | make sure you set a port in your config file (~/.ssb/config).
|
12 |
|
13 | ``` json
|
14 | {
|
15 | "ws": {"port": 8989}
|
16 | }
|
17 | ```
|
18 |
|
19 | ## adding your own http handlers
|
20 |
|
21 | sometimes you need to do http, here is an example sbot plugin that
|
22 | exposes the websocket address.
|
23 |
|
24 | ``` js
|
25 | require('scuttlebot')
|
26 | .use(require('ssb-ws'))
|
27 | .use({
|
28 | name: 'test123',
|
29 | version: '1.0.0',
|
30 | init: function (sbot) {
|
31 | sbot.ws.use(function (req, res, next) {
|
32 | if(req.url == '/get-address')
|
33 | res.end(sbot.ws.getAddress())
|
34 | else next()
|
35 | })
|
36 | }
|
37 | })
|
38 | ```
|
39 |
|
40 | ## License
|
41 |
|
42 | MIT
|
43 |
|