Feat: make compute schema middleware for 'db' changing

This commit is contained in:
csrapr 2021-03-03 15:43:20 +00:00 committed by Josh Harvey
parent 7bbf2829de
commit cbf0165893
2 changed files with 15 additions and 0 deletions

12
lib/compute-schema.js Normal file
View file

@ -0,0 +1,12 @@
const { asyncLocalStorage } = require('./async-storage')
const computeSchema = (req, res, next) => {
const store = new Map()
store.set('schema', 'public')
store.set('defaultSchema', 'ERROR_SCHEMA')
asyncLocalStorage.run(store, () => {
next()
})
}
module.exports = computeSchema