Fix request rate limit option not working

This commit is contained in:
Ajay
2022-10-27 20:00:04 -04:00
parent ccd1321d24
commit 96db571a5e
2 changed files with 2 additions and 3 deletions

View File

@@ -80,7 +80,7 @@ function setupRoutes(router: Router) {
// Rate limit endpoint lists
const voteEndpoints: RequestHandler[] = [voteOnSponsorTime];
const viewEndpoints: RequestHandler[] = [viewedVideoSponsorTime];
if (config.rateLimit) {
if (config.rateLimit && config.redisRateLimit) {
if (config.rateLimit.vote) voteEndpoints.unshift(rateLimitMiddleware(config.rateLimit.vote, voteGetUserID));
if (config.rateLimit.view) viewEndpoints.unshift(rateLimitMiddleware(config.rateLimit.view));
}

View File

@@ -32,8 +32,7 @@ export function rateLimitMiddleware(limitConfig: RateLimitConfig, getUserID?: (r
}
},
store: config.redis?.enabled ? new RedisStore({
sendCommand: (...args: string[]) => config.redisRateLimit ? redis.sendCommand(args).catch((err) => Logger.error(err)) as Promise<RedisReply>
: Promise.resolve(null) as Promise<RedisReply>,
sendCommand: (...args: string[]) => redis.sendCommand(args).catch((err) => Logger.error(err)) as Promise<RedisReply>,
}) : null,
});
} catch (e) {