Adding check to disable rate limit redis connection in test.

This commit is contained in:
mike12345567 2022-03-02 12:50:10 +00:00
parent a8a8498a9c
commit 32e7f27dfa
1 changed files with 13 additions and 11 deletions

View File

@ -22,8 +22,9 @@ const { getRedisOptions } = require("@budibase/backend-core/redis").utils
const PREFIX = "/api/public/v1" const PREFIX = "/api/public/v1"
const DEFAULT_API_LIMITING = 120 const DEFAULT_API_LIMITING = 120
const REDIS_OPTS = getRedisOptions() if (!env.isTest()) {
RateLimit.defaultOptions({ const REDIS_OPTS = getRedisOptions()
RateLimit.defaultOptions({
store: new Stores.Redis({ store: new Stores.Redis({
socket: { socket: {
host: REDIS_OPTS.host, host: REDIS_OPTS.host,
@ -32,7 +33,8 @@ RateLimit.defaultOptions({
password: REDIS_OPTS.opts.password, password: REDIS_OPTS.opts.password,
database: 1, database: 1,
}), }),
}) })
}
// rate limiting, allows for 2 requests per second // rate limiting, allows for 2 requests per second
const limiter = RateLimit.middleware({ const limiter = RateLimit.middleware({
interval: { min: 1 }, interval: { min: 1 },