git ssb

10+

Matt McKegg / patchwork



Tree: f096230a58e0b7b3a85a61e839a6088a8fe434c2

Files: f096230a58e0b7b3a85a61e839a6088a8fe434c2 / modules / index.js

935 bytesRaw
1var SbotApi = require('../api')
2var extend = require('xtend')
3var combine = require('depject')
4var fs = require('fs')
5var patchbayModules = require('patchbay/modules')
6
7module.exports = function (config, ssbClient, overrides) {
8 var api = SbotApi(ssbClient, config)
9 var localModules = getLocalModules()
10 return combine(extend(patchbayModules, localModules, {
11 'sbot-api.js': api,
12 'blob-url.js': {
13 blob_url: function (link) {
14 var prefix = config.blobsPrefix != null ? config.blobsPrefix : `http://localhost:${config.blobsPort}`
15 if (typeof link.link === 'string') {
16 link = link.link
17 }
18 return `${prefix}/${encodeURIComponent(link)}`
19 }
20 }
21 }, overrides))
22}
23
24function getLocalModules () {
25 return fs.readdirSync(__dirname).reduce(function (result, e) {
26 if (e !== 'index.js' && /\js$/.test(e)) {
27 result[e] = require('./' + e)
28 }
29 return result
30 }, {})
31}
32

Built with git-ssb-web