File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 11import PinoHttp from 'pino-http' ;
2+ import rateLimit from 'express-rate-limit' ;
23import { handleDockerDesktopSubsitution } from './docker-desktop-substitution' ;
34import { filters } from './request-filters' ;
45
@@ -142,9 +143,18 @@ export const makeHandleRequest = () => {
142143 } ;
143144} ;
144145
146+ // Rate limiter: Max 100 requests per 1 minutes per IP
147+ const limiter = rateLimit ( {
148+ windowMs : 1 * 60 * 1000 ,
149+ max : 100 ,
150+ message : 'Too many requests from this IP, please try again later.' ,
151+ standardHeaders : true ,
152+ legacyHeaders : false ,
153+ } ) ;
154+
145155export const serveStaticApp = ( app , requestPath , directoryPath ) => {
146156 app . use ( requestPath , express . static ( path . join ( __dirname , directoryPath ) ) ) ;
147- app . get ( requestPath + '*splat' , ( _ , res ) =>
157+ app . get ( requestPath + '*splat' , limiter , ( _ , res ) =>
148158 res . sendFile ( path . join ( __dirname + directoryPath + '/index.html' ) ) ,
149159 ) ;
150160} ;
You can’t perform that action at this time.
0 commit comments