Closing global DB using the standard function - not directly.

This commit is contained in:
mike12345567 2022-04-20 18:07:48 +01:00
parent 7792a07899
commit 9ee1be79fb
1 changed files with 3 additions and 1 deletions

View File

@ -1,4 +1,5 @@
const { setTenantId, setGlobalDB, getGlobalDB } = require("../tenancy")
const { closeDB } = require("../db")
const ContextFactory = require("../context/FunctionContext")
const { buildMatcherRegex, matches } = require("./matchers")
@ -18,7 +19,8 @@ module.exports = (
setGlobalDB(tenantId)
}
const destroyFn = async () => {
await getGlobalDB().close()
const db = getGlobalDB()
await closeDB(db)
}
return ContextFactory.getMiddleware(updateCtxFn, destroyFn)