simplify couchDB configuration
This commit is contained in:
parent
f07dcf7f55
commit
af4c1b23de
|
@ -166,6 +166,12 @@ exports.getCouchUrl = () => {
|
||||||
|
|
||||||
const [protocol, ...rest] = env.COUCH_DB_URL.split("://")
|
const [protocol, ...rest] = env.COUCH_DB_URL.split("://")
|
||||||
|
|
||||||
|
if (!env.COUCH_DB_USERNAME || !env.COUCH_DB_PASSWORD) {
|
||||||
|
throw new Error(
|
||||||
|
"CouchDB configuration invalid. You must provide a fully qualified CouchDB url, or the COUCH_DB_USER and COUCH_DB_PASSWORD environment variables."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return `${protocol}://${env.COUCH_DB_USERNAME}:${env.COUCH_DB_PASSWORD}@${rest}`
|
return `${protocol}://${env.COUCH_DB_USERNAME}:${env.COUCH_DB_PASSWORD}@${rest}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ function isTest() {
|
||||||
module.exports = {
|
module.exports = {
|
||||||
JWT_SECRET: process.env.JWT_SECRET,
|
JWT_SECRET: process.env.JWT_SECRET,
|
||||||
COUCH_DB_URL: process.env.COUCH_DB_URL,
|
COUCH_DB_URL: process.env.COUCH_DB_URL,
|
||||||
COUCH_DB_USERNAME: process.env.COUCH_DB_USER || process.env.COUCH_DB_USERNAME,
|
COUCH_DB_USERNAME: process.env.COUCH_DB_USER,
|
||||||
COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD,
|
COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD,
|
||||||
SALT_ROUNDS: process.env.SALT_ROUNDS,
|
SALT_ROUNDS: process.env.SALT_ROUNDS,
|
||||||
REDIS_URL: process.env.REDIS_URL,
|
REDIS_URL: process.env.REDIS_URL,
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
const PouchDB = require("pouchdb")
|
const PouchDB = require("pouchdb")
|
||||||
|
const { getCouchUrl } = require("@budibase/auth/db")
|
||||||
const replicationStream = require("pouchdb-replication-stream")
|
const replicationStream = require("pouchdb-replication-stream")
|
||||||
const allDbs = require("pouchdb-all-dbs")
|
const allDbs = require("pouchdb-all-dbs")
|
||||||
const find = require("pouchdb-find")
|
const find = require("pouchdb-find")
|
||||||
const env = require("../environment")
|
const env = require("../environment")
|
||||||
|
|
||||||
const COUCH_DB_URL = env.COUCH_DB_URL || "http://localhost:10000/db/"
|
const COUCH_DB_URL = getCouchUrl() || "http://localhost:10000/db/"
|
||||||
|
|
||||||
PouchDB.plugin(replicationStream.plugin)
|
PouchDB.plugin(replicationStream.plugin)
|
||||||
PouchDB.plugin(find)
|
PouchDB.plugin(find)
|
||||||
|
@ -14,13 +15,6 @@ let POUCH_DB_DEFAULTS = {
|
||||||
prefix: COUCH_DB_URL,
|
prefix: COUCH_DB_URL,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env.COUCH_DB_USERNAME && env.COUCH_DB_PASSWORD) {
|
|
||||||
POUCH_DB_DEFAULTS.auth = {
|
|
||||||
username: env.COUCH_DB_USERNAME,
|
|
||||||
password: env.COUCH_DB_PASSWORD,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (env.isTest()) {
|
if (env.isTest()) {
|
||||||
PouchDB.plugin(require("pouchdb-adapter-memory"))
|
PouchDB.plugin(require("pouchdb-adapter-memory"))
|
||||||
POUCH_DB_DEFAULTS = {
|
POUCH_DB_DEFAULTS = {
|
||||||
|
|
|
@ -24,8 +24,6 @@ module.exports = {
|
||||||
PORT: process.env.PORT,
|
PORT: process.env.PORT,
|
||||||
JWT_SECRET: process.env.JWT_SECRET,
|
JWT_SECRET: process.env.JWT_SECRET,
|
||||||
COUCH_DB_URL: process.env.COUCH_DB_URL,
|
COUCH_DB_URL: process.env.COUCH_DB_URL,
|
||||||
COUCH_DB_USERNAME: process.env.COUCH_DB_USER,
|
|
||||||
COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD,
|
|
||||||
MINIO_URL: process.env.MINIO_URL,
|
MINIO_URL: process.env.MINIO_URL,
|
||||||
WORKER_URL: process.env.WORKER_URL,
|
WORKER_URL: process.env.WORKER_URL,
|
||||||
SELF_HOSTED: process.env.SELF_HOSTED,
|
SELF_HOSTED: process.env.SELF_HOSTED,
|
||||||
|
|
|
@ -1,21 +1,15 @@
|
||||||
const PouchDB = require("pouchdb")
|
const PouchDB = require("pouchdb")
|
||||||
const allDbs = require("pouchdb-all-dbs")
|
const allDbs = require("pouchdb-all-dbs")
|
||||||
const env = require("../environment")
|
const env = require("../environment")
|
||||||
|
const { getCouchUrl } = require("@budibase/auth/db")
|
||||||
|
|
||||||
// level option is purely for testing (development)
|
// level option is purely for testing (development)
|
||||||
const COUCH_DB_URL = env.COUCH_DB_URL || "http://localhost:10000/db/"
|
const COUCH_DB_URL = getCouchUrl() || "http://localhost:10000/db/"
|
||||||
|
|
||||||
let POUCH_DB_DEFAULTS = {
|
let POUCH_DB_DEFAULTS = {
|
||||||
prefix: COUCH_DB_URL,
|
prefix: COUCH_DB_URL,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env.COUCH_DB_USERNAME && env.COUCH_DB_PASSWORD) {
|
|
||||||
POUCH_DB_DEFAULTS.auth = {
|
|
||||||
username: env.COUCH_DB_USERNAME,
|
|
||||||
password: env.COUCH_DB_PASSWORD,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (env.isTest()) {
|
if (env.isTest()) {
|
||||||
PouchDB.plugin(require("pouchdb-adapter-memory"))
|
PouchDB.plugin(require("pouchdb-adapter-memory"))
|
||||||
POUCH_DB_DEFAULTS = {
|
POUCH_DB_DEFAULTS = {
|
||||||
|
|
Loading…
Reference in New Issue