Formatting.

This commit is contained in:
mike12345567 2021-04-27 17:30:19 +01:00
parent 129b827d9f
commit 01a9db76c8
3 changed files with 22 additions and 23 deletions

View File

@ -17,7 +17,7 @@ function init() {
return new Promise((resolve, reject) => {
const [host, port] = env.REDIS_URL.split(":")
const opts = {
connectTimeout: CONNECT_TIMEOUT_MS
connectTimeout: CONNECT_TIMEOUT_MS,
}
if (CLUSTERED) {
opts.redisOptions = {}
@ -58,7 +58,7 @@ function promisifyStream(stream) {
outputKeys.add(key)
})
})
stream.on("error", (err) => {
stream.on("error", err => {
reject(err)
})
stream.on("end", async () => {
@ -69,10 +69,12 @@ function promisifyStream(stream) {
getPromises.push(CLIENT.get(key))
}
const jsonArray = await Promise.all(getPromises)
resolve(keysArray.map(key => ({
resolve(
keysArray.map(key => ({
key: removeDbPrefix(key),
value: JSON.parse(jsonArray.shift()),
})))
}))
)
} catch (err) {
reject(err)
}
@ -91,12 +93,12 @@ class RedisWrapper {
}
async scan() {
const db = this._db, client = this._client
const db = this._db,
client = this._client
let stream
if (CLUSTERED) {
let node = client.nodes("master")
stream = node[0].scanStream({ match: db + "-*", count: 100 })
} else {
stream = client.scanStream({ match: db + "-*", count: 100 })
}
@ -104,7 +106,8 @@ class RedisWrapper {
}
async get(key) {
const db = this._db, client = this._client
const db = this._db,
client = this._client
let response = await client.get(addDbPrefix(db, key))
// overwrite the prefixed key
if (response != null && response.key) {
@ -114,8 +117,9 @@ class RedisWrapper {
}
async store(key, value, expirySeconds = null) {
const db = this._db, client = this._client
if (typeof(value) === "object") {
const db = this._db,
client = this._client
if (typeof value === "object") {
value = JSON.stringify(value)
}
const prefixedKey = addDbPrefix(db, key)
@ -126,7 +130,8 @@ class RedisWrapper {
}
async delete(key) {
const db = this._db, client = this._client
const db = this._db,
client = this._client
await client.del(addDbPrefix(db, key))
}

View File

@ -47,7 +47,6 @@ exports.reset = async ctx => {
try {
const user = getGlobalUserByEmail(email)
if (user) {
}
} catch (err) {
// don't throw any kind of error to the user, this might give away something

View File

@ -1,11 +1,7 @@
const nodemailer = require("nodemailer")
const CouchDB = require("../db")
const { StaticDatabases, determineScopedConfig } = require("@budibase/auth").db
const {
EmailTemplatePurpose,
TemplateTypes,
Configs,
} = require("../constants")
const { EmailTemplatePurpose, TemplateTypes, Configs } = require("../constants")
const { getTemplateByPurpose } = require("../constants/templates")
const { getSettingsTemplateContext } = require("./templates")
const { processString } = require("@budibase/string-templates")
@ -94,7 +90,6 @@ exports.sendEmail = async (email, purpose, { groupId, userId }) => {
return transport.sendMail(message)
}
exports.verifyConfig = async config => {
const transport = createSMTPTransport(config)
await transport.verify()