git ssb

1+

dinoworm ๐Ÿ› / vas



Tree: 0b4d6451ce5d4f2f2c503793f5ac1c61b10bc4ac

Files: 0b4d6451ce5d4f2f2c503793f5ac1c61b10bc4ac / createServer.js

797 bytesRaw
1var muxrpc = require('muxrpc')
2var setIn = require('set-in')
3
4var serialize = require('./serialize')
5var walkApi = require('./walkApi')
6
7module.exports = createServer
8
9function createServer (api, config) {
10
11 var manifest = {}
12 var permissions = {}
13 var local = {}
14
15 walkApi(api, function (service, path) {
16 // merge manifest
17 setIn(manifest, path, service.manifest)
18 // merge permissions
19 setIn(permissions, path, service.permissions)
20 // merge local by calling service.init(api, config)
21 setIn(local, path, service.init(api, config))
22 })
23 return {
24 createRpc,
25 createStream
26 }
27
28 function createRpc () {
29 var Rpc = muxrpc(null, manifest, serialize)
30 return Rpc(local, permissions)
31 }
32
33 function createStream() {
34 return createRpc().createStream()
35 }
36}
37
38

Built with git-ssb-web