Skip to content

Commit

Permalink
Add rate limit to api calls (5000/15min).
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew-Grayson committed Mar 6, 2024
1 parent 89fc86d commit c196f08
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"cors": "^2.8.5",
"date-fns": "^3.3.1",
"express": "^4.18.1",
"express-rate-limit": "^7.2.0",
"global-agent": "^2.2.0",
"got": "^11.8.5",
"handlebars": "^4.7.8",
Expand Down
8 changes: 8 additions & 0 deletions backend/src/api/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as stats from './stats';
import * as apiKeys from './api-keys';
import * as reports from './reports';
import * as savedSearches from './saved-searches';
import rateLimit from 'express-rate-limit';
import { createProxyMiddleware } from 'http-proxy-middleware';
import { UserType } from '../models';

Expand Down Expand Up @@ -57,6 +58,13 @@ const handlerToExpress = (handler) => async (req, res) => {

const app = express();

app.use(
rateLimit({
windowMs: 15 * 60 * 1000,
limit: 5000
})
); // limit 1000 requests per 15 minutes

app.use(express.json({ strict: false }));

app.use(
Expand Down

0 comments on commit c196f08

Please sign in to comment.