(req, res, next)
| 301 | } |
| 302 | |
| 303 | const 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 | |
| 332 | export const handleParseSession = async (req, res, next) => { |
| 333 | try { |
no test coverage detected