improve redis auth

This commit is contained in:
SrGooglo 2023-07-05 19:06:25 +00:00
parent 0a17e141a9
commit be4e2a3cd9

View File

@ -21,11 +21,19 @@ function composeURL() {
export default ({ export default ({
withWsAdapter = false withWsAdapter = false
} = {}) => { } = {}) => {
let client = createClient({ let clientOpts = {
url: composeURL(), url: composeURL(),
password: process.env.REDIS_PASSWORD, }
username: process.env.REDIS_USERNAME,
}) if (process.env.REDIS_PASSWORD) {
clientOpts.password = process.env.REDIS_PASSWORD
}
if (process.env.REDIS_USERNAME) {
clientOpts.username = process.env.REDIS_USERNAME
}
let client = createClient()
if (withWsAdapter) { if (withWsAdapter) {
client.subClient = client.duplicate() client.subClient = client.duplicate()