From 32e7f27dfa7093b8eea7e0d5c3480cbc5cddb55c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 2 Mar 2022 12:50:10 +0000 Subject: [PATCH] Adding check to disable rate limit redis connection in test. --- .../server/src/api/routes/public/index.ts | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/server/src/api/routes/public/index.ts b/packages/server/src/api/routes/public/index.ts index 911977ba1d..c4d8247b66 100644 --- a/packages/server/src/api/routes/public/index.ts +++ b/packages/server/src/api/routes/public/index.ts @@ -22,17 +22,19 @@ const { getRedisOptions } = require("@budibase/backend-core/redis").utils const PREFIX = "/api/public/v1" const DEFAULT_API_LIMITING = 120 -const REDIS_OPTS = getRedisOptions() -RateLimit.defaultOptions({ - store: new Stores.Redis({ - socket: { - host: REDIS_OPTS.host, - port: REDIS_OPTS.port, - }, - password: REDIS_OPTS.opts.password, - database: 1, - }), -}) +if (!env.isTest()) { + const REDIS_OPTS = getRedisOptions() + RateLimit.defaultOptions({ + store: new Stores.Redis({ + socket: { + host: REDIS_OPTS.host, + port: REDIS_OPTS.port, + }, + password: REDIS_OPTS.opts.password, + database: 1, + }), + }) +} // rate limiting, allows for 2 requests per second const limiter = RateLimit.middleware({ interval: { min: 1 },