Skip to content

Commit b3196ea

Browse files
✨ (CodeQL) Fixed finding: "Missing rate limiting"
1 parent 9066cee commit b3196ea

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

examples/express/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
'use strict';
22

33
var express = require('express');
4+
var rateLimit = require('express-rate-limit');
45
var app = express();
56
var Server = require('http').Server;
67
var server = new Server(app);
78

9+
var limiter = rateLimit({
10+
windowMs: 15 * 60 * 1000, // 15 minutes
11+
max: 100 // limit each IP to 100 requests per windowMs
12+
});
13+
14+
app.use(limiter);
15+
816
server.listen(8080);
917

10-
// __dirname is used here along with package.json.pkg.assets
11-
// see https://github.com/zeit/pkg#config and
12-
// https://github.com/zeit/pkg#snapshot-filesystem
1318
app.use('/', express.static(__dirname + '/views'));
1419

1520
app.get('/', function (req, res) {

0 commit comments

Comments
 (0)