MCPcopy Index your code
hub / github.com/parse-community/parse-server / handleRateLimit

Function handleRateLimit

src/middlewares.js:303–330  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

301}
302
303const handleRateLimit = async (req, res, next) => {
304 const rateLimits = req.config.rateLimits || [];
305 try {
306 await Promise.all(
307 rateLimits.map(async limit => {
308 const pathExp = limit.path.regexp || limit.path;
309 if (pathExp.test(req.url)) {
310 await limit.handler(req, res, err => {
311 if (err) {
312 if (err.code === Parse.Error.CONNECTION_FAILED) {
313 throw err;
314 }
315 req.config.loggerController.error(
316 'An unknown error occured when attempting to apply the rate limiter: ',
317 err
318 );
319 }
320 });
321 }
322 })
323 );
324 } catch (error) {
325 res.status(429);
326 res.json({ code: Parse.Error.CONNECTION_FAILED, error: error.message });
327 return;
328 }
329 next();
330};
331
332export const handleParseSession = async (req, res, next) => {
333 try {

Callers 1

handleParseHeadersFunction · 0.85

Calls 3

nextFunction · 0.85
errorMethod · 0.80
handlerMethod · 0.45

Tested by

no test coverage detected