Updating auth lib so that it takes in a pouch instance rather than creating its own.
This commit is contained in:
parent
fb4e52baff
commit
2edb559fcf
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue