Files: 62ee1b7bfd9fae4bbec8650f48cc6d5494403927 / 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