Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise {
// init redis
const redis = Redis.createHandyClient({
host: process.env.RedisHost,
password: process.env.RedisKey,
port: 6380,
tls: process.env.RedisHost
})
// TODO generate SAS token(s)
const tokens = Array()
const expireTokenAt = Moment().add(1, 'day')
const sasTokenService = new SasTokenService()
const queues = ['check-submitted', 'check-started', 'pupil-prefs', 'pupil-feedback']
queues.forEach((q) => {
const token = sasTokenService.generateSasToken(q, expireTokenAt)
tokens.push(token)
})
// TODO load all pupils via SQL (schoolUUID(urlSlug), pupilUUID(urlSlug))
import { createHandyClient } from "handy-redis";
import { REDIS_URL } from "../config";
import { logError } from "./errors";
export const redis = createHandyClient({
url: REDIS_URL,
retry_strategy: options => {
if (options.error && options.error.code === "ECONNREFUSED") {
logError("Redis connection failed", "Server refused the connection");
}
if (options.total_retry_time > 1000 * 60 * 60) {
logError("Redis connection failed", "Total retry time exhausted");
}
if (options.attempt > 10) {
logError("Redis connection failed", "Max number of attempts exceeded");
return 43200;
}
// Reconnect after this time
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise {
// init redis
const redis = Redis.createHandyClient({
host: process.env.RedisHost,
password: process.env.RedisKey,
port: 6380,
tls: process.env.RedisHost
})
const tokens = Array()
const expireTokenAt = Moment().add(1, 'day')
const sasTokenService = new SasTokenService()
const queues = ['check-submitted', 'check-started', 'pupil-prefs', 'pupil-feedback']
queues.forEach((q) => {
const token = sasTokenService.generateSasToken(q, expireTokenAt)
tokens.push(token)
})
// TODO load all pupils via SQL (schoolUUID(urlSlug), pupilUUID(urlSlug))