Files: 340ef7cdcc9255c17889664920a134eca6611486 / index.js
926 bytesRaw
1 | var create = require('./create') |
2 | var path = require('path') |
3 | var Inject = require('./inject') |
4 | var Set = require('./set') |
5 | var Level = require('level') |
6 | |
7 | exports.manifest = { |
8 | get: 'source', |
9 | getSlice: 'source', |
10 | add: 'sink', |
11 | rm: 'async', |
12 | ls: 'source', |
13 | has: 'async', |
14 | size: 'async', |
15 | meta: 'async', |
16 | want: 'async', |
17 | push: 'async', |
18 | changes: 'source', |
19 | createWants: 'source' |
20 | } |
21 | |
22 | exports.name = 'blobs' |
23 | |
24 | exports.version = require('./package.json').version |
25 | |
26 | exports.permissions = { |
27 | anonymous: {allow: ['has', 'get', 'getSlice', 'changes', 'createWants']}, |
28 | } |
29 | |
30 | exports.init = function (sbot, config) { |
31 | var blobs = Inject( |
32 | create(path.join(config.path, 'blobs')), |
33 | Set(Level(path.join(config.path, 'blobs_push'), {valueEncoding: 'json'})), |
34 | sbot.id, |
35 | config.blobs |
36 | ) |
37 | |
38 | sbot.on('rpc:connect', function (rpc) { |
39 | if (rpc.id === sbot.id) return |
40 | blobs._onConnect(rpc, rpc.id) |
41 | }) |
42 | return blobs |
43 | } |
44 | |
45 |
Built with git-ssb-web