-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
35 lines (31 loc) · 817 Bytes
/
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
'use strict'
const IPFSDaemon = require('ipfs-daemon/src/ipfs-node-daemon')
const IPFSGoDaemon = require('ipfs-daemon/src/ipfs-native-daemon')
let ipfs
const IpfsApis = [
{
// js-ipfs
name: 'js-ipfs',
start: (options) => {
return new Promise((resolve, reject) => {
ipfs = new IPFSDaemon(options)
ipfs.on('ready', () => resolve(ipfs))
ipfs.on('error', (e) => reject(e))
})
},
stop: () => ipfs.stop()
},
{
// js-ipfs-api via local daemon
name: 'js-ipfs-api',
start: (options) => {
return new Promise((resolve, reject) => {
ipfs = new IPFSGoDaemon(options)
ipfs.on('ready', () => resolve(ipfs))
ipfs.on('error', (e) => reject(e))
})
},
stop: () => ipfs.stop()
}
]
module.exports = IpfsApis