Add standalone support if ssb-client can't connect
This commit is contained in:
parent
f6ab49f785
commit
1c491d73c1
12
package.json
12
package.json
@ -16,10 +16,20 @@
|
|||||||
"open": "^6.3.0",
|
"open": "^6.3.0",
|
||||||
"pretty-ms": "^5.0.0",
|
"pretty-ms": "^5.0.0",
|
||||||
"pull-stream": "^3.6.12",
|
"pull-stream": "^3.6.12",
|
||||||
|
"secret-stack": "^6.2.0",
|
||||||
|
"ssb-about": "^2.0.1",
|
||||||
|
"ssb-backlinks": "^0.7.3",
|
||||||
|
"ssb-blobs": "^1.2.1",
|
||||||
"ssb-client": "^4.7.7",
|
"ssb-client": "^4.7.7",
|
||||||
|
"ssb-config": "^3.3.1",
|
||||||
|
"ssb-db": "^19.3.0",
|
||||||
|
"ssb-gossip": "^1.1.0",
|
||||||
"ssb-markdown": "github:ssbc/ssb-markdown#no-target-blank",
|
"ssb-markdown": "github:ssbc/ssb-markdown#no-target-blank",
|
||||||
|
"ssb-master": "^1.0.3",
|
||||||
"ssb-msgs": "^5.2.0",
|
"ssb-msgs": "^5.2.0",
|
||||||
"ssb-ref": "^2.13.9"
|
"ssb-ref": "^2.13.9",
|
||||||
|
"ssb-replicate": "^1.3.0",
|
||||||
|
"ssb-ws": "^6.2.3"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"oasis": "./index.js"
|
"oasis": "./index.js"
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
const ssbClient = require('ssb-client')
|
const ssbClient = require('ssb-client')
|
||||||
|
const secretStack = require('secret-stack')
|
||||||
|
const ssbConfig = require('ssb-config')
|
||||||
|
|
||||||
// a water cooler API
|
const server = secretStack()
|
||||||
module.exports = {
|
|
||||||
|
const db = {
|
||||||
connect: function () {
|
connect: function () {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ssbClient((err, api) => {
|
ssbClient((err, api) => {
|
||||||
@ -27,3 +30,22 @@ module.exports = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
db.connect().then(() =>
|
||||||
|
console.log('Using pre-existing Scuttlebutt server instead of starting one')
|
||||||
|
).catch(() => {
|
||||||
|
console.log('Starting Scuttlebutt server')
|
||||||
|
|
||||||
|
server
|
||||||
|
.use(require('ssb-db'))
|
||||||
|
.use(require('ssb-master'))
|
||||||
|
.use(require('ssb-gossip'))
|
||||||
|
.use(require('ssb-replicate'))
|
||||||
|
.use(require('ssb-backlinks'))
|
||||||
|
.use(require('ssb-about'))
|
||||||
|
.use(require('ssb-blobs'))
|
||||||
|
.use(require('ssb-ws'))
|
||||||
|
server(ssbConfig)
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = db
|
||||||
|
Loading…
Reference in New Issue
Block a user