mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-30 17:37:26 +00:00 
			
		
		
		
	pr feedback
Signed-off-by: Derrick Mehaffy <derrickmehaffy@gmail.com>
This commit is contained in:
		
							parent
							
								
									7576d8a257
								
							
						
					
					
						commit
						cf4b74c4f4
					
				| @ -9,10 +9,12 @@ module.exports = | ||||
|   async (ctx, next) => { | ||||
|     const ratelimit = require('koa2-ratelimit').RateLimit; | ||||
| 
 | ||||
|     const userEmail = ctx.request.body.email || 'unknownEmail'; | ||||
| 
 | ||||
|     return ratelimit.middleware({ | ||||
|       interval: { min: 15 }, | ||||
|       interval: { min: 5 }, | ||||
|       max: 5, | ||||
|       prefixKey: `${ctx.request.path}:${ctx.request.ip}`, | ||||
|       prefixKey: `${userEmail}${ctx.request.path}:${ctx.request.ip}`, | ||||
|       handler() { | ||||
|         throw new RateLimitError(); | ||||
|       }, | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| 'use strict'; | ||||
| 
 | ||||
| const createError = require('http-errors'); | ||||
| const { NotFoundError, UnauthorizedError, ForbiddenError, PayloadTooLargeError, PolicyError } = | ||||
| const { NotFoundError, UnauthorizedError, ForbiddenError, PayloadTooLargeError, RateLimitError } = | ||||
|   require('@strapi/utils').errors; | ||||
| 
 | ||||
| const mapErrorsAndStatus = [ | ||||
| @ -22,7 +22,7 @@ const mapErrorsAndStatus = [ | ||||
|     status: 413, | ||||
|   }, | ||||
|   { | ||||
|     classError: PolicyError, | ||||
|     classError: RateLimitError, | ||||
|     status: 429, | ||||
|   }, | ||||
| ]; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 derrickmehaffy
						derrickmehaffy