diff --git a/backend/ratelimit.ts b/backend/ratelimit.ts index 7e6a31d..77115f1 100644 --- a/backend/ratelimit.ts +++ b/backend/ratelimit.ts @@ -38,7 +38,7 @@ export const setRateLimiter = (group: string, config: EndpointRateLimitConfigura * creates middleware for rate limiting */ export const rateLimiterMiddleware = (group: string, config: EndpointRateLimitConfiguration | undefined): (req: Request, res: Response, next: NextFunction) => void => { - if (rateLimiterGroups.has(group)) setRateLimiter(group, config); + if (!rateLimiterGroups.has(group)) setRateLimiter(group, config); return (req, res, next) => { return rateLimiterGroups.get(group)!(req, res, next); diff --git a/backend/routers/api.ts b/backend/routers/api.ts index c0d1ca5..3383b5e 100644 --- a/backend/routers/api.ts +++ b/backend/routers/api.ts @@ -35,6 +35,11 @@ router.post('/setup', BodyParserJson(), async (req, res) => { if (UserConfig.config.rateLimit?.login) setRateLimiter('login', UserConfig.config.rateLimit.login); if (UserConfig.config.rateLimit?.upload) setRateLimiter('upload', UserConfig.config.rateLimit.upload); + // set rate limits + if (UserConfig.config.rateLimit?.api) setRateLimiter('api', UserConfig.config.rateLimit.api); + if (UserConfig.config.rateLimit?.login) setRateLimiter('login', UserConfig.config.rateLimit.login); + if (UserConfig.config.rateLimit?.upload) setRateLimiter('upload', UserConfig.config.rateLimit.upload); + log.success('Setup', 'completed'); return res.json({ success: true });