Feat: adds async local storage to admin server
This commit is contained in:
parent
8128f05ffb
commit
cb2e1b3907
5 changed files with 47 additions and 8 deletions
|
|
@ -3,10 +3,11 @@ const express = require('express')
|
|||
const router = express.Router()
|
||||
const hkdf = require('futoin-hkdf')
|
||||
const session = require('express-session')
|
||||
const pgSession = require('connect-pg-simple')(session)
|
||||
const PgSession = require('connect-pg-simple')(session)
|
||||
const mnemonicHelpers = require('../../mnemonic-helpers')
|
||||
const db = require('../../db')
|
||||
const options = require('../../options')
|
||||
const { USER_SESSIONS_TABLE_NAME } = require('../../constants')
|
||||
|
||||
const getSecret = () => {
|
||||
const mnemonic = fs.readFileSync(options.mnemonicPath, 'utf8')
|
||||
|
|
@ -19,10 +20,14 @@ const getSecret = () => {
|
|||
|
||||
const hostname = options.hostname
|
||||
|
||||
const lamaDb = {
|
||||
query: (query, values, qrm) => db.$query(query, values, qrm, false)
|
||||
}
|
||||
|
||||
router.use('*', session({
|
||||
store: new pgSession({
|
||||
pgPromise: db,
|
||||
tableName: 'user_sessions'
|
||||
store: new PgSession({
|
||||
pgPromise: lamaDb,
|
||||
tableName: USER_SESSIONS_TABLE_NAME
|
||||
}),
|
||||
name: 'lid',
|
||||
secret: getSecret(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue