Browse Source

Adding check to disable rate limit redis connection in test.

master
mike12345567 5 years ago
parent
commit
32e7f27dfa
  1. 24
      packages/server/src/api/routes/public/index.ts

24
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 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()
store: new Stores.Redis({ RateLimit.defaultOptions({
socket: { store: new Stores.Redis({
host: REDIS_OPTS.host, socket: {
port: REDIS_OPTS.port, host: REDIS_OPTS.host,
}, port: REDIS_OPTS.port,
password: REDIS_OPTS.opts.password, },
database: 1, password: REDIS_OPTS.opts.password,
}), 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 },

Loading…
Cancel
Save