git ssb

10+

Matt McKegg / patchwork



Tree: b6089670d854fcefa6bc5ca05636a801707deb30

Files: b6089670d854fcefa6bc5ca05636a801707deb30 / 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