Closing global DB using the standard function - not directly.

This commit is contained in:
mike12345567 2022-04-20 18:07:48 +01:00
parent 9899781fc5
commit 6afe3a28ef
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)