Files: 7ff9053605e6aa539b6e50d0d18ce3c3b7fc5523 / index.js
877 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 | add: 'sink', |
10 | ls: 'source', |
11 | has: 'async', |
12 | size: 'async', |
13 | meta: 'async', |
14 | want: 'async', |
15 | push: 'async', |
16 | changes: 'source', |
17 | createWants: 'source' |
18 | } |
19 | |
20 | exports.name = 'blobs' |
21 | |
22 | exports.version = require('./package.json').version |
23 | |
24 | exports.permissions = { |
25 | anonymous: {allow: ['has', 'get', 'changes', 'createWants']}, |
26 | } |
27 | |
28 | exports.init = function (sbot, config) { |
29 | var blobs = Inject( |
30 | create(path.join(config.path, 'blobs')), |
31 | Set(Level(path.join(config.path, 'blobs_push'), {valueEncoding: 'json'})), |
32 | sbot.id, |
33 | config.blobs |
34 | ) |
35 | |
36 | sbot.on('rpc:connect', function (rpc) { |
37 | if (rpc.id === sbot.id) return |
38 | blobs._onConnect(rpc, rpc.id) |
39 | }) |
40 | return blobs |
41 | } |
42 | |
43 |
Built with git-ssb-web