diff --git a/src/index.ts b/src/index.ts index f17a8f1..1bc9028 100644 --- a/src/index.ts +++ b/src/index.ts @@ -116,21 +116,23 @@ app.use(compression()); app.set('trust proxy', 1); app.use(logHttp); app.use(handleResponseTime); -app.use( - rateLimit({ - windowMs: 1000, // 1 second - max: rateLimitCallsPerSecond, - standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers - legacyHeaders: false, // Disable the `X-RateLimit-*` headers - skip: (req, _res) => { - if (!loadTestAllowed) { - return false; - } +if (!FEATURE_FLAGS.DISABLE_RATE_LIMIT) { + app.use( + rateLimit({ + windowMs: 1000, // 1 second + max: rateLimitCallsPerSecond, + standardHeaders: true, // Return rate limit info in the `RateLimit-*` headers + legacyHeaders: false, // Disable the `X-RateLimit-*` headers + skip: (req, _res) => { + if (!loadTestAllowed) { + return false; + } - return req.headers['user-agent'].includes('k6'); - }, - }) -); + return req.headers['user-agent'].includes('k6'); + }, + }) + ); +} // strip off /dlob, if the request comes from exchange history server LB app.use((req, _res, next) => { diff --git a/src/utils/featureFlags.ts b/src/utils/featureFlags.ts index f815837..7c6d724 100644 --- a/src/utils/featureFlags.ts +++ b/src/utils/featureFlags.ts @@ -12,6 +12,10 @@ export const FEATURE_FLAGS = { DISABLE_GPA_REFRESH: process.env.DISABLE_GPA_REFRESH ? process.env.DISABLE_GPA_REFRESH.toLowerCase() === 'true' : false, + + DISABLE_RATE_LIMIT: process.env.DISABLE_RATE_LIMIT + ? process.env.DISABLE_RATE_LIMIT.toLowerCase() === 'true' + : false, }; export default FEATURE_FLAGS;