Updating auth lib so that it takes in a pouch instance rather than creating its own.

This commit is contained in:
mike12345567 2021-04-15 16:45:21 +01:00
parent aacfb6adba
commit 9e1315c535
5 changed files with 20 additions and 12 deletions

View File

@ -12,7 +12,6 @@
"passport-google-auth": "^1.0.2",
"passport-google-oauth": "^2.0.0",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"pouchdb": "^7.2.2"
"passport-local": "^1.0.0"
}
}

View File

@ -1,12 +1,9 @@
const PouchDB = require("pouchdb")
const env = require("../environment")
let Pouch
// level option is purely for testing (development)
const COUCH_DB_URL =
env.COUCH_DB_URL || "http://budibase:budibase@localhost:10000/db/"
module.exports.getDB = () => {
return Pouch
}
const Pouch = PouchDB.defaults({
prefix: COUCH_DB_URL,
})
module.exports = Pouch
module.exports.setDB = pouch => {
Pouch = pouch
}

View File

@ -1,3 +1,4 @@
const db = require("./db")
const passport = require("koa-passport")
const LocalStrategy = require("passport-local").Strategy
const JwtStrategy = require("passport-jwt").Strategy
@ -40,6 +41,9 @@ passport.deserializeUser(async (user, done) => {
})
module.exports = {
init(pouch) {
db.setDB(pouch)
},
passport,
Cookies,
UserStatus,

View File

@ -11,6 +11,10 @@ const eventEmitter = require("./events")
const automations = require("./automations/index")
const Sentry = require("@sentry/node")
const fileSystem = require("./utilities/fileSystem")
const auth = require("@budibase/auth")
const CouchDB = require("./db")
auth.init(CouchDB)
const app = new Koa()

View File

@ -7,6 +7,10 @@ const { passport } = require("@budibase/auth")
const logger = require("koa-pino-logger")
const http = require("http")
const api = require("./api")
const auth = require("@budibase/auth")
const CouchDB = require("./db")
auth.init(CouchDB)
const app = new Koa()