File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 11import { Router } from 'express'
2+ import rateLimit from 'express-rate-limit'
23import { authenticateToken } from '../middlewares/authenticate.js'
34import { getImage , create , uploadSingle } from '../controllers/images.js'
45import { Validation } from '../helpers/validator.js'
@@ -13,8 +14,14 @@ const imageRateLimiter = rateLimit({
1314 legacyHeaders : false , // Disable the `X-RateLimit-*` headers
1415} )
1516
16- export const ROUTE = Router ( )
17+ // Set up rate limiter: max 100 requests per 15 minutes per IP
18+ const limiter = rateLimit ( {
19+ windowMs : 15 * 60 * 1000 , // 15 minutes
20+ max : 100 , // limit each IP to 100 requests per windowMs
21+ } )
1722
23+ export const ROUTE = Router ( )
24+ ROUTE . use ( limiter )
1825ROUTE . get ( "/" , Validation . base . list , async ( req , res ) => {
1926 const response = await ImageModel . getData ( req . query )
2027 res . send ( response )
You can’t perform that action at this time.
0 commit comments