Files: 13be5ee9906beb5d8c2a24db46c68ef183c78d3a / modules / index.js
935 bytesRaw
1 | var SbotApi = require('../api') |
2 | var extend = require('xtend') |
3 | var combine = require('depject') |
4 | var fs = require('fs') |
5 | var patchbayModules = require('patchbay/modules') |
6 | |
7 | module.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 | |
24 | function 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