misc: finalized backend flow

This commit is contained in:
Sheen Capadngan
2024-06-13 16:27:13 +08:00
parent 810a58c836
commit d5658d374a
5 changed files with 39 additions and 33 deletions
+11 -9
View File
@@ -61,20 +61,22 @@ export const publicEndpointLimit: RateLimitOptions = {
keyGenerator: (req) => req.realIp
};
export const globalRateLimiterCfg = async (rateLimits: TRateLimit): Promise<RateLimitPluginOptions> => {
export const globalRateLimiterCfg = async (rateLimits?: TRateLimit): Promise<RateLimitPluginOptions> => {
const appCfg = getConfig();
const redis = appCfg.isRedisConfigured
? new Redis(appCfg.REDIS_URL, { connectTimeout: 500, maxRetriesPerRequest: 1 })
: null;
readLimit.max = rateLimits.readRateLimit;
publicEndpointLimit.max = rateLimits.publicEndpointLimit;
writeLimit.max = rateLimits.writeRateLimit;
secretsLimit.max = rateLimits.secretsRateLimit;
authRateLimit.max = rateLimits.authRateLimit;
inviteUserRateLimit.max = rateLimits.inviteUserRateLimit;
mfaRateLimit.max = rateLimits.mfaRateLimit;
creationLimit.max = rateLimits.creationLimit;
if (rateLimits) {
readLimit.max = rateLimits.readRateLimit;
publicEndpointLimit.max = rateLimits.publicEndpointLimit;
writeLimit.max = rateLimits.writeRateLimit;
secretsLimit.max = rateLimits.secretsRateLimit;
authRateLimit.max = rateLimits.authRateLimit;
inviteUserRateLimit.max = rateLimits.inviteUserRateLimit;
mfaRateLimit.max = rateLimits.mfaRateLimit;
creationLimit.max = rateLimits.creationLimit;
}
return {
timeWindow: 60 * 1000,