diff --git a/packages/backend-core/src/index.ts b/packages/backend-core/src/index.ts index c7cf9f56cc..d41f2b9384 100644 --- a/packages/backend-core/src/index.ts +++ b/packages/backend-core/src/index.ts @@ -37,6 +37,7 @@ export { SearchParams } from "./db" // circular dependencies import * as context from "./context" import * as _tenancy from "./tenancy" +import * as redis from "./redis" export const tenancy = { ..._tenancy, ...context, @@ -50,6 +51,8 @@ export * from "./constants" // expose package init function import * as db from "./db" -export const init = (opts: any = {}) => { + +export const init = async (opts: any = {}) => { db.init(opts.db) + await redis.init() } diff --git a/packages/backend-core/src/redis/index.ts b/packages/backend-core/src/redis/index.ts index 419f1db700..cc9eb854b4 100644 --- a/packages/backend-core/src/redis/index.ts +++ b/packages/backend-core/src/redis/index.ts @@ -4,6 +4,7 @@ export { default as Client } from "./redis" export * as utils from "./utils" export * as clients from "./init" export * as locks from "./redlockImpl" +export * from "./init" export * from "./invite" export * from "./passwordReset" diff --git a/packages/backend-core/src/redis/init.ts b/packages/backend-core/src/redis/init.ts index a4f1fecc17..8f2d2914b5 100644 --- a/packages/backend-core/src/redis/init.ts +++ b/packages/backend-core/src/redis/init.ts @@ -11,7 +11,7 @@ let userClient: Client, inviteClient: Client, passwordResetClient: Client -async function init() { +export async function init() { userClient = await new Client(utils.Databases.USER_CACHE).init() sessionClient = await new Client(utils.Databases.SESSIONS).init() appClient = await new Client(utils.Databases.APP_METADATA).init() diff --git a/packages/worker/src/db/index.ts b/packages/worker/src/db/index.ts index 157c2f4fb3..19f8f8acee 100644 --- a/packages/worker/src/db/index.ts +++ b/packages/worker/src/db/index.ts @@ -1,7 +1,7 @@ import * as core from "@budibase/backend-core" import env from "../environment" -export function init() { +export async function init() { const dbConfig: any = { replication: true, find: true, @@ -12,5 +12,5 @@ export function init() { dbConfig.allDbs = true } - core.init({ db: dbConfig }) + await core.init({ db: dbConfig }) }