-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·41 lines (35 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const assert = require('assert')
const {join} = require('path')
const globals = require('./globals')
const {getEnvVar} = require('./lib/env')
const dweb = require('./dweb')
const ddbs = require('./ddbs')
const webapis = require('./web-apis/bg')
module.exports = {
getEnvVar,
globals,
dweb,
ddbs,
setup (opts) {
assert(typeof opts.userDataPath === 'string', 'userDataPath must be a string')
assert(typeof opts.homePath === 'string', 'homePath must be a string')
assert(!!opts.permsAPI, 'must provide permsAPI')
assert(!!opts.uiAPI, 'must provide uiAPI')
assert(!!opts.rpcAPI, 'must provide rpcAPI')
assert(!!opts.downloadsWebAPI, 'must provide downloadsWebAPI')
assert(!!opts.browserWebAPI, 'must provide browserWebAPI')
for (let k in opts) {
globals[k] = opts[k]
}
// setup databases
for (let k in ddbs) {
if (ddbs[k].setup) {
ddbs[k].setup(opts)
}
}
// setup dWeb
dweb.repository.setup({logfilePath: join(globals.userDataPath, 'dweb.log')})
// setup web apis
webapis.setup(opts)
}
}