git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Tree: 68976cde98459b3f066c8c3c0fab7c054a4d848c

Files: 68976cde98459b3f066c8c3c0fab7c054a4d848c / 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