fix(sever): wrong rate limiter being used for result post

also lowers limit slightly to 300 and updates the generic message to be more clear
This commit is contained in:
Miodec 2024-08-27 22:50:20 +02:00
parent a6232beea5
commit 6e43e1c4dc
2 changed files with 3 additions and 3 deletions

View file

@ -22,7 +22,7 @@ export default s.router(resultsContract, {
handler: async (r) => callController(ResultController.getResults)(r),
},
add: {
middleware: [validateResultSavingEnabled, RateLimit.resultsTagsUpdate],
middleware: [validateResultSavingEnabled, RateLimit.resultsAdd],
handler: async (r) => callController(ResultController.addResult)(r),
},
updateTags: {

View file

@ -29,7 +29,7 @@ export const customHandler = (
_next: NextFunction,
_options: Options
): void => {
throw new MonkeyError(429, "Too many attempts, please try again later.");
throw new MonkeyError(429, "Request limit reached, please try again later.");
};
const ONE_HOUR_SECONDS = 60 * 60;
@ -277,7 +277,7 @@ export const resultsGetApe = rateLimit({
export const resultsAdd = rateLimit({
windowMs: ONE_HOUR_MS,
max: 500 * REQUEST_MULTIPLIER,
max: 300 * REQUEST_MULTIPLIER,
keyGenerator: getKeyWithUid,
handler: customHandler,
});