Skip to content

Commit 1a5248a

Browse files
authored
chore: Bump express (#3894)
* Bump express * add Konrad as code owner * remove changes from code owners * Try this * fix Code scanning results / CodeQL
1 parent 14ca124 commit 1a5248a

File tree

3 files changed

+970
-512
lines changed

3 files changed

+970
-512
lines changed

backend/common.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import PinoHttp from 'pino-http';
2+
import rateLimit from 'express-rate-limit';
23
import { handleDockerDesktopSubsitution } from './docker-desktop-substitution';
34
import { 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+
145155
export const serveStaticApp = (app, requestPath, directoryPath) => {
146156
app.use(requestPath, express.static(path.join(__dirname, directoryPath)));
147-
app.get(requestPath + '*', (_, res) =>
157+
app.get(requestPath + '*splat', limiter, (_, res) =>
148158
res.sendFile(path.join(__dirname + directoryPath + '/index.html')),
149159
);
150160
};

0 commit comments

Comments
 (0)