Add standalone support if ssb-client can't connect

This commit is contained in:
Christian Bundy 2019-06-28 09:13:35 -07:00
parent f6ab49f785
commit 1c491d73c1
No known key found for this signature in database
GPG Key ID: EB541AAEF4366237
3 changed files with 2010 additions and 50 deletions

View File

@ -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"

View File

@ -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

2022
yarn.lock

File diff suppressed because it is too large Load Diff