Commit 2ab67531b8a5ecdd7419f3c8d9fa0ccee8cb9377
revert to scuttlebot@11.4.3 LTS
Ev Bogue committed on 2/3/2019, 5:36:02 PMParent: 863e8a538677038443dd0724e2e80cf71c5b62a0
Files changed
bin.js | changed |
config.js | changed |
config/inject.js | changed |
package-lock.json | changed |
package.json | changed |
query/index.js | added |
bin.js | |||
---|---|---|---|
@@ -1,106 +1,76 @@ | |||
1 | -#! /usr/bin/env node | ||
2 | - | ||
3 | -var fs = require('fs') | ||
4 | -var path = require('path') | ||
5 | -var pull = require('pull-stream') | ||
6 | -var toPull = require('stream-to-pull-stream') | ||
7 | -var File = require('pull-file') | ||
8 | -var explain = require('explain-error') | ||
9 | -var ssbKeys = require('ssb-keys') | ||
10 | -var stringify = require('pull-stringify') | ||
11 | -var createHash = require('multiblob/util').createHash | ||
12 | -var minimist = require('minimist') | ||
13 | -var muxrpcli = require('muxrpcli') | ||
14 | -var cmdAliases = require('scuttlebot/lib/cli-cmd-aliases') | ||
15 | -var ProgressBar = require('scuttlebot/lib/progress') | ||
16 | -var packageJson = require('scuttlebot/package.json') | ||
1 … | +var fs = require('fs') | ||
2 … | +var path = require('path') | ||
3 … | +var ssbKeys = require('ssb-keys') | ||
4 … | +var stringify = require('pull-stringify') | ||
17 | 5 … | var open = require('opn') | |
6 … | +var home = require('os-homedir')() | ||
7 … | +var nonPrivate = require('non-private-ip') | ||
8 … | +var muxrpcli = require('muxrpcli') | ||
18 | 9 … | ||
19 | -//get config as cli options after --, options before that are | ||
20 | -//options to the command. | ||
21 | -var argv = process.argv.slice(2) | ||
22 | -var i = argv.indexOf('--') | ||
23 | -var conf = argv.slice(i+1) | ||
24 | -argv = ~i ? argv.slice(0, i) : argv | ||
10 … | +var SEC = 1e3 | ||
11 … | +var MIN = 60*SEC | ||
25 | 12 … | ||
26 | -var config = require('./config/inject')(process.env.ssb_appname, minimist(conf)) | ||
13 … | +var network = 'ssb' | ||
14 … | +//var network = 'decent' | ||
15 … | +//var network = 'testnet' | ||
27 | 16 … | ||
28 | -var keys = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret')) | ||
29 | -if(keys.curve === 'k256') | ||
30 | - throw new Error('k256 curves are no longer supported,'+ | ||
31 | - 'please delete' + path.join(config.path, 'secret')) | ||
17 … | +var config = require('./config/inject')(network) | ||
32 | 18 … | ||
33 | -var compiledClient = fs.readFileSync(path.join('./build/index.html')) | ||
19 … | +config.keys = ssbKeys.loadOrCreateSync(path.join(config.path, 'secret')) | ||
34 | 20 … | ||
21 … | +var mvdClient = fs.readFileSync(path.join('./build/index.html')) | ||
22 … | + | ||
35 | 23 … | var manifestFile = path.join(config.path, 'manifest.json') | |
36 | 24 … | ||
25 … | +var argv = process.argv.slice(2) | ||
26 … | +var i = argv.indexOf('--') | ||
27 … | +var conf = argv.slice(i+1) | ||
28 … | +argv = ~i ? argv.slice(0, i) : argv | ||
29 … | + | ||
37 | 30 … | if (argv[0] == 'server') { | |
38 | - console.log(packageJson.name, packageJson.version, config.path, 'logging.level:'+config.logging.level) | ||
39 | - console.log('my key ID:', keys.public) | ||
40 | - | ||
41 | - // special server command: | ||
42 | - // import sbot and start the server | ||
43 | - | ||
44 | - var createSbot = require('scuttlebot') | ||
45 | - .use(require('scuttlebot/plugins/unix-socket')) | ||
46 | - .use(require('scuttlebot/plugins/no-auth')) | ||
47 | - .use(require('scuttlebot/plugins/plugins')) | ||
48 | - .use(require('scuttlebot/plugins/master')) | ||
49 | - .use(require('scuttlebot/plugins/gossip')) | ||
50 | - .use(require('scuttlebot/plugins/replicate')) | ||
31 … | + | ||
32 … | + var createSbot = require('scuttlebot-release/node_modules/scuttlebot') | ||
33 … | + .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/master')) | ||
34 … | + .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/gossip')) | ||
35 … | + .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/replicate')) | ||
51 | 36 … | .use(require('ssb-friends')) | |
52 | 37 … | .use(require('ssb-blobs')) | |
53 | - .use(require('scuttlebot/plugins/invite')) | ||
54 | - .use(require('scuttlebot/plugins/local')) | ||
55 | - .use(require('scuttlebot/plugins/logging')) | ||
56 | - .use(require('ssb-query')) | ||
57 | 38 … | .use(require('ssb-backlinks')) | |
39 … | + .use(require('./query')) | ||
40 … | + .use(require('ssb-links')) | ||
41 … | + .use(require('ssb-ebt')) | ||
58 | 42 … | .use(require('ssb-search')) | |
59 | - .use(require('./mvd-indexes')) | ||
60 | - .use(require('ssb-links')) | ||
43 … | + .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/invite')) | ||
44 … | + .use(require('scuttlebot-release/node_modules/scuttlebot/plugins/local')) | ||
61 | 45 … | .use(require('decent-ws')) | |
62 | - .use(require('ssb-ebt')) | ||
63 | 46 … | .use({ | |
64 | 47 … | name: 'serve', | |
65 | 48 … | version: '1.0.0', | |
66 | 49 … | init: function (sbot) { | |
67 | 50 … | sbot.ws.use(function (req, res, next) { | |
68 | 51 … | var send = config | |
69 | - delete send.keys | ||
70 | - /*sbot.invite.create(1, function (err, cb) { | ||
52 … | + delete send.keys // very important to keep this, as it removes the server keys from the config before broadcast | ||
53 … | + send.address = sbot.ws.getAddress() | ||
54 … | + sbot.invite.create({modern: true}, function (err, cb) { | ||
71 | 55 … | send.invite = cb | |
72 | - })*/ | ||
73 | - send.address = sbot.getAddress() | ||
56 … | + }) | ||
74 | 57 … | if(req.url == '/') | |
75 | - res.end(compiledClient) | ||
58 … | + res.end(mvdClient) | ||
76 | 59 … | if(req.url == '/get-config') | |
77 | 60 … | res.end(JSON.stringify(send)) | |
78 | 61 … | else next() | |
79 | 62 … | }) | |
80 | 63 … | } | |
81 | 64 … | }) | |
82 | - // add third-party plugins | ||
83 | - require('scuttlebot/plugins/plugins').loadUserPlugins(createSbot, config) | ||
84 | - | ||
85 | - // start server | ||
86 | - | ||
65 … | + | ||
87 | 66 … | open('http://localhost:' + config.ws.port, {wait: false}) | |
88 | - | ||
89 | - config.keys = keys | ||
67 … | + | ||
90 | 68 … | var server = createSbot(config) | |
91 | - | ||
92 | - // write RPC manifest to ~/.ssb/manifest.json | ||
69 … | + | ||
93 | 70 … | fs.writeFileSync(manifestFile, JSON.stringify(server.getManifest(), null, 2)) | |
94 | - | ||
95 | - if(process.stdout.isTTY && (config.logging.level != 'info')) | ||
96 | - ProgressBar(server.progress) | ||
97 | 71 … | } else { | |
98 | 72 … | ||
99 | - // normal command: | ||
100 | - // create a client connection to the server | ||
101 | - | ||
102 | - // read manifest.json | ||
103 | 73 … | var manifest | |
104 | 74 … | try { | |
105 | 75 … | manifest = JSON.parse(fs.readFileSync(manifestFile)) | |
106 | 76 … | } catch (err) { | |
@@ -110,73 +80,37 @@ | |||
110 | 80 … | ) | |
111 | 81 … | } | |
112 | 82 … | ||
113 | 83 … | // connect | |
114 | - require('ssb-client')(keys, { | ||
84 … | + require('ssb-client')(config.keys, { | ||
115 | 85 … | manifest: manifest, | |
116 | 86 … | port: config.port, | |
117 | 87 … | host: config.host||'localhost', | |
118 | 88 … | caps: config.caps, | |
119 | - key: config.key || keys.id | ||
89 … | + key: config.key || config.keys.id | ||
120 | 90 … | }, function (err, rpc) { | |
121 | 91 … | if(err) { | |
122 | 92 … | if (/could not connect/.test(err.message)) { | |
123 | - var serverAddr = (config.host || 'localhost') + ":" + config.port; | ||
124 | - console.error('Error: Could not connect to the scuttlebot server ' + serverAddr) | ||
125 | - console.error('Use the "server" command to start it.') | ||
93 … | + console.log('Error: Could not connect to the scuttlebot server.') | ||
94 … | + console.log('Use the "server" command to start it.') | ||
126 | 95 … | if(config.verbose) throw err | |
127 | 96 … | process.exit(1) | |
128 | 97 … | } | |
129 | 98 … | throw err | |
130 | 99 … | } | |
131 | 100 … | ||
132 | - // add aliases | ||
133 | - for (var k in cmdAliases) { | ||
134 | - rpc[k] = rpc[cmdAliases[k]] | ||
135 | - manifest[k] = manifest[cmdAliases[k]] | ||
136 | - } | ||
137 | - | ||
138 | 101 … | // add some extra commands | |
139 | -// manifest.version = 'async' | ||
102 … | + manifest.version = 'async' | ||
140 | 103 … | manifest.config = 'sync' | |
141 | -// rpc.version = function (cb) { | ||
142 | -// console.log(packageJson.version) | ||
143 | -// cb() | ||
144 | -// } | ||
104 … | + rpc.version = function (cb) { | ||
105 … | + console.log(require('./package.json').version) | ||
106 … | + cb() | ||
107 … | + } | ||
145 | 108 … | rpc.config = function (cb) { | |
146 | 109 … | console.log(JSON.stringify(config, null, 2)) | |
147 | 110 … | cb() | |
148 | 111 … | } | |
149 | 112 … | ||
150 | - // HACK | ||
151 | - // we need to output the hash of blobs that are added via blobs.add | ||
152 | - // because muxrpc doesnt support the `sink` callback yet, we need this manual override | ||
153 | - // -prf | ||
154 | - if (process.argv[2] === 'blobs.add') { | ||
155 | - var filename = process.argv[3] | ||
156 | - var source = | ||
157 | - filename ? File(process.argv[3]) | ||
158 | - : !process.stdin.isTTY ? toPull.source(process.stdin) | ||
159 | - : (function () { | ||
160 | - console.error('USAGE:') | ||
161 | - console.error(' blobs.add <filename> # add a file') | ||
162 | - console.error(' source | blobs.add # read from stdin') | ||
163 | - process.exit(1) | ||
164 | - })() | ||
165 | - var hasher = createHash('sha256') | ||
166 | - pull( | ||
167 | - source, | ||
168 | - hasher, | ||
169 | - rpc.blobs.add(function (err) { | ||
170 | - if (err) | ||
171 | - throw err | ||
172 | - console.log('&'+hasher.digest) | ||
173 | - process.exit() | ||
174 | - }) | ||
175 | - ) | ||
176 | - return | ||
177 | - } | ||
178 | - | ||
179 | 113 … | // run commandline flow | |
180 | 114 … | muxrpcli(argv, manifest, rpc, config.verbose) | |
181 | 115 … | }) | |
182 | 116 … | } |
config.js | ||
---|---|---|
@@ -2,9 +2,8 @@ | ||
2 | 2 … | |
3 | 3 … | module.exports = function () { |
4 | 4 … | var host = window.location.origin |
5 | 5 … | |
6 | - //var config = require('./config/inject')() | |
7 | 6 … | function getConfig () { |
8 | 7 … | http.get(host + '/get-config', function (res) { |
9 | 8 … | res.on('data', function (data, remote) { |
10 | 9 … | var config = data |
@@ -21,15 +20,15 @@ | ||
21 | 20 … | setTimeout(function () { |
22 | 21 … | location.reload() |
23 | 22 … | }, 1000) |
24 | 23 … | } |
25 | - config.host = host | |
24 … | + | |
26 | 25 … | config.blobsUrl = host + '/blobs/get/' |
27 | 26 … | config.emojiUrl = host + '/img/emoji/' |
28 | 27 … | |
29 | - if (config.address) { | |
30 | - addies = config.address.split(';') | |
31 | - config.remote = addies[1] | |
32 | - } | |
28 … | + if (config.ws.remote) | |
29 … | + config.remote = config.ws.remote | |
30 … | + else | |
31 … | + config.remote = config.address | |
33 | 32 … | |
34 | 33 … | return config |
35 | 34 … | } |
config/inject.js | ||
---|---|---|
@@ -1,73 +1,81 @@ | ||
1 | 1 … | var path = require('path') |
2 | 2 … | var home = require('os-homedir') |
3 | - | |
4 | 3 … | var nonPrivate = require('non-private-ip') |
5 | 4 … | var merge = require('deep-extend') |
6 | - | |
5 … | +var id = require('ssb-keys') | |
7 | 6 … | var RC = require('rc') |
8 | - | |
9 | 7 … | var SEC = 1e3 |
10 | 8 … | var MIN = 60*SEC |
11 | 9 … | |
12 | 10 … | module.exports = function (name, override) { |
13 | - name = name || 'ssb' | |
11 … | + console.log('Using the ' + name + ' config') | |
12 … | + | |
13 … | + var network | |
14 … | + | |
15 … | + if (name === 'ssb') { | |
16 … | + network = { | |
17 … | + port: 8008, | |
18 … | + ws: { | |
19 … | + port: 8989 | |
20 … | + }, | |
21 … | + caps: { | |
22 … | + shs: '1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=', | |
23 … | + sign: null | |
24 … | + } | |
25 … | + } | |
26 … | + } | |
27 … | + | |
28 … | + if (name === 'decent') { | |
29 … | + network = { | |
30 … | + port: 3333, | |
31 … | + ws: { | |
32 … | + port: 3939 | |
33 … | + }, | |
34 … | + caps: { | |
35 … | + shs: 'EVRctE2Iv8GrO/BpQCF34e2FMPsDJot9x0j846LjVtc=', | |
36 … | + sign: null | |
37 … | + } | |
38 … | + } | |
39 … | + } | |
40 … | + | |
41 … | + if (name === 'testnet') { | |
42 … | + network = { | |
43 … | + port: 9999, | |
44 … | + ws: { | |
45 … | + port: 9191 | |
46 … | + }, | |
47 … | + caps: { | |
48 … | + shs: 'sR74I0+OW6LBYraQQ2YtFtqV5Ns77Tv5DyMfyWbrlpI=', | |
49 … | + sign: null | |
50 … | + } | |
51 … | + } | |
52 … | + } | |
53 … | + | |
14 | 54 … | var HOME = home() || 'browser' //most probably browser |
15 | - var result = RC(name || 'ssb', merge({ | |
16 | - //just use an ipv4 address by default. | |
17 | - //there have been some reports of seemingly non-private | |
18 | - //ipv6 addresses being returned and not working. | |
19 | - //https://github.com/ssbc/scuttlebot/pull/102 | |
20 | - allowPrivate: true, | |
21 | - party: true, | |
55 … | + | |
56 … | + return RC(name, merge(network, { | |
57 … | + name: name, | |
58 … | + //standard stuff that probably doesn't need to change below | |
22 | 59 … | host: nonPrivate.v4 || '', |
23 | - port: 8008, | |
24 | 60 … | timeout: 0, |
61 … | + allowPrivate: true, | |
25 | 62 … | pub: true, |
26 | 63 … | local: true, |
27 | 64 … | friends: { |
28 | 65 … | dunbar: 150, |
29 | 66 … | hops: 3 |
30 | 67 … | }, |
31 | - ws: { | |
32 | - port: 8989 | |
33 | - }, | |
34 | 68 … | gossip: { |
35 | 69 … | connections: 3 |
36 | 70 … | }, |
37 | - connections: { | |
38 | - outgoing: { | |
39 | - net: [{ transform: "shs" }] | |
40 | - } | |
41 | - }, | |
42 | 71 … | path: path.join(HOME, '.' + name), |
43 | 72 … | timers: { |
44 | 73 … | connection: 0, |
45 | 74 … | reconnect: 5*SEC, |
46 | 75 … | ping: 5*MIN, |
47 | 76 … | handshake: 5*SEC |
48 | 77 … | }, |
49 | - //change these to make a test network that will not connect to the main network. | |
50 | - caps: { | |
51 | - //this is the key for accessing the ssb protocol. | |
52 | - //this will be updated whenever breaking changes are made. | |
53 | - //(see secret-handshake paper for a full explaination) | |
54 | - //(generated by crypto.randomBytes(32).toString('base64')) | |
55 | - shs: '1KHLiKZvAvjbY1ziZEHMXawbCEIM6qwjCDm3VYRan/s=', | |
56 | - | |
57 | - //used to sign messages | |
58 | - sign: null | |
59 | - }, | |
60 | 78 … | master: [], |
61 | - logging: { level: 'notice' } | |
79 … | + party: true //disable quotas | |
62 | 80 … | }, override || {})) |
63 | - | |
64 | - if (!result.connections.incoming) { | |
65 | - result.connections.incoming = { | |
66 | - net: [{ host: result.host, port: result.port, scope: "public", "transform": "shs" }], | |
67 | - ws: [{ host: result.host, port: result.ws.port, scope: "public", "transform": "shs" }] | |
68 | - } | |
69 | - } | |
70 | - return result | |
71 | 81 … | } |
72 | - | |
73 | - |
package-lock.json | ||
---|---|---|
The diff is too large to show. Use a local git client to view these changes. Old file size: 237872 bytes New file size: 303372 bytes |
package.json | ||
---|---|---|
@@ -1,7 +1,7 @@ | ||
1 | 1 … | { |
2 | 2 … | "name": "mvd", |
3 | - "version": "1.15.3", | |
3 … | + "version": "1.16.0", | |
4 | 4 … | "description": "minimum viable decent", |
5 | 5 … | "main": "index.js", |
6 | 6 … | "scripts": { |
7 | 7 … | "start": "node bin server", |
@@ -10,50 +10,51 @@ | ||
10 | 10 … | "testnet": "node bin server --appname=testnet", |
11 | 11 … | "build": "node style.js && mkdir -p build && browserify index.js | indexhtmlify > build/index.html" |
12 | 12 … | }, |
13 | 13 … | "devDependencies": { |
14 | - "browserify": "^16.2.3", | |
14 … | + "browserify": "^16.2.2", | |
15 | 15 … | "indexhtmlify": "^1.3.1" |
16 | 16 … | }, |
17 | 17 … | "author": "Ev Bogue <ev@evbogue.com>", |
18 | 18 … | "license": "MIT", |
19 | 19 … | "dependencies": { |
20 | 20 … | "dataurl-": "^0.1.0", |
21 | - "decent-ws": "^1.1.0", | |
21 … | + "decent-ws": "1.0.4", | |
22 | 22 … | "deep-extend": "^0.6.0", |
23 | 23 … | "diff": "^3.5.0", |
24 | - "flumeview-query": "^7.1.0", | |
24 … | + "emoji-server": "^1.0.0", | |
25 | 25 … | "human-time": "0.0.1", |
26 | 26 … | "hyperfile": "^2.0.0", |
27 | 27 … | "hyperloadmore": "^1.1.0", |
28 | 28 … | "hyperscript": "^2.0.2", |
29 | 29 … | "hyperscroll": "^1.0.0", |
30 … | + "multiblob-http": "^0.4.2", | |
30 | 31 … | "muxrpcli": "^1.1.0", |
31 | - "non-private-ip": "^1.4.4", | |
32 | - "opn": "^5.4.0", | |
32 … | + "non-private-ip": "^1.4.3", | |
33 … | + "opn": "^5.3.0", | |
33 | 34 … | "os-homedir": "^1.0.2", |
34 | 35 … | "pull-more": "^1.1.0", |
35 | 36 … | "pull-next-query": "^1.0.0", |
36 | 37 … | "pull-reconnect": "0.0.3", |
37 | - "pull-stream": "^3.6.9", | |
38 … | + "pull-stream": "^3.6.8", | |
38 | 39 … | "pull-stringify": "^2.0.0", |
39 | - "rc": "^1.2.8", | |
40 | - "scuttlebot": "13.0.3", | |
40 … | + "rc": "^1.2.7", | |
41 … | + "scuttlebot-release": "ssbc/scuttlebot-release#11.3.x-fixups", | |
41 | 42 … | "simple-mime": "^0.1.0", |
42 | 43 … | "split-buffer": "^1.0.0", |
43 | 44 … | "ssb-avatar": "^0.2.0", |
44 | - "ssb-backlinks": "^0.7.3", | |
45 | - "ssb-blobs": "^1.1.6", | |
46 | - "ssb-client": "^4.6.0", | |
47 | - "ssb-ebt": "^5.2.7", | |
45 … | + "ssb-backlinks": "^0.7.1", | |
46 … | + "ssb-blobs": "^1.1.5", | |
47 … | + "ssb-client": "^4.5.7", | |
48 … | + "ssb-ebt": "^5.1.5", | |
48 | 49 … | "ssb-feed": "^2.3.0", |
49 | - "ssb-friends": "^3.1.6", | |
50 | - "ssb-keys": "^7.1.3", | |
50 … | + "ssb-friends": "^2.4.0", | |
51 … | + "ssb-keys": "^7.0.16", | |
51 | 52 … | "ssb-links": "^3.0.3", |
52 | 53 … | "ssb-markdown": "^3.6.0", |
53 | 54 … | "ssb-mentions": "^0.5.0", |
54 | - "ssb-query": "^2.3.0", | |
55 | - "ssb-ref": "^2.13.6", | |
56 | - "ssb-search": "^1.1.2", | |
55 … | + "ssb-ref": "^2.11.1", | |
56 … | + "ssb-search": "^1.0.1", | |
57 … | + "stack": "^0.1.0", | |
57 | 58 … | "visualize-buffer": "0.0.1" |
58 | 59 … | } |
59 | 60 … | } |
query/index.js | ||
---|---|---|
@@ -1,0 +1,68 @@ | ||
1 … | +var pull = require('pull-stream') | |
2 … | +var path = require('path') | |
3 … | +var FlumeQuery = require('flumeview-query') | |
4 … | +var explain = require('explain-error') | |
5 … | + | |
6 … | +function isString(s) { | |
7 … | + return 'string' === typeof s | |
8 … | +} | |
9 … | + | |
10 … | +exports.name = 'query' | |
11 … | +exports.version = '1.0.0' | |
12 … | +exports.manifest = { | |
13 … | + read: 'source', | |
14 … | + explain: 'sync' | |
15 … | +} | |
16 … | + | |
17 … | +//what are links used for? | |
18 … | +//query follows | |
19 … | +//query replies | |
20 … | +//query mentions (backlinks & mentions) | |
21 … | +//query votes | |
22 … | + | |
23 … | + | |
24 … | +var INDEX_VERSION = 8 | |
25 … | +var indexes = [ | |
26 … | + {key: 'log', value: ['timestamp']}, | |
27 … | + {key: 'clk', value: [['value', 'author'], ['value', 'sequence']] }, | |
28 … | + {key: 'typ', value: [['value', 'content', 'type'], ['timestamp']] }, | |
29 … | + {key: 'tya', value: [['value', 'content', 'type'], ['value', 'timestamp']] }, | |
30 … | + {key: 'cha', value: [['value', 'content', 'channel'], ['timestamp']] }, | |
31 … | + {key: 'aty', value: [['value', 'author'], ['value', 'content', 'type'], ['timestamp']]}, | |
32 … | + {key: 'ata', value: [['value', 'author'], ['value', 'content', 'type'], ['value', 'timestamp']]}, | |
33 … | + {key: 'art', value: [['value', 'content', 'root'], ['value', 'timestamp']]}, | |
34 … | + {key: 'lor', value: [['value', 'timestamp' ]]} | |
35 … | +] | |
36 … | + | |
37 … | +//createHistoryStream( id, seq ) | |
38 … | +//[{$filter: {author: <id>, sequence: {$gt: <seq>}}}, {$map: true}] | |
39 … | + | |
40 … | +//messagesByType (type) | |
41 … | + | |
42 … | +//[{$filter: {content: {type: <type>}}}, {$map: true}] | |
43 … | + | |
44 … | +exports.init = function (ssb, config) { | |
45 … | + var s = ssb._flumeUse('query', FlumeQuery(INDEX_VERSION, {indexes: indexes})) | |
46 … | + var read = s.read | |
47 … | + var explain = s.explain | |
48 … | + s.explain = function (opts) { | |
49 … | + if(!opts) opts = {} | |
50 … | + if(isString(opts)) | |
51 … | + opts = {query: JSON.parse(opts)} | |
52 … | + else if(isString(opts.query)) | |
53 … | + opts.query = JSON.parse(opts.query) | |
54 … | + return explain(opts) | |
55 … | + } | |
56 … | + | |
57 … | + s.read = function (opts) { | |
58 … | + if(!opts) opts = {} | |
59 … | + if(isString(opts)) | |
60 … | + opts = {query: JSON.parse(opts)} | |
61 … | + else if(isString(opts.query)) | |
62 … | + opts.query = JSON.parse(opts.query) | |
63 … | + return read(opts) | |
64 … | + } | |
65 … | + return s | |
66 … | +} | |
67 … | + | |
68 … | + |
Built with git-ssb-web