Skip to content

Commit

Permalink
add express-rate-limit to example
Browse files Browse the repository at this point in the history
  • Loading branch information
jkasten2 committed Oct 25, 2023
1 parent 27ed361 commit d924672
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions express_webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"license": "ISC",
"dependencies": {
"express": "^4.17.3",
"express-rate-limit": "^7.1.2",
"fs": "0.0.1-security",
"https": "^1.0.0",
"nodemon": "^1.19.3",
Expand Down
10 changes: 10 additions & 0 deletions express_webpack/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ const express = require('express');
const https = require('https');
const fs = require('fs');
var sanitize = require("sanitize-filename");

const app = express(),
DIST_DIR = __dirname,
HTML_FILE = path.join(DIST_DIR, 'index.html'),
SDK_FILES = path.join(DIST_DIR, '../build/releases/');

var RateLimit = require('express-rate-limit');
var limiter = RateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // max 100 requests per windowMs
});
// apply rate limiter to all requests
app.use(limiter);

const options = {
key: fs.readFileSync('certs/dev-ssl.key'),
cert: fs.readFileSync('certs/dev-ssl.crt')
Expand Down
5 changes: 5 additions & 0 deletions express_webpack/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,11 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2:
dependencies:
homedir-polyfill "^1.0.1"

express-rate-limit@^7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/express-rate-limit/-/express-rate-limit-7.1.2.tgz#42156c9135ca7b77d4e0d74b06162bfe02cd45f7"
integrity sha512-uvkFt5JooXDhUhrfgqXLyIsAMRCtU1o8W/p0Q2p5U2ude7fEOfFaP0kSYbHOHmPbA9ZEm1JqrRne3vL9pVCBXA==

express@^4.17.3:
version "4.17.3"
resolved "https://registry.yarnpkg.com/express/-/express-4.17.3.tgz#f6c7302194a4fb54271b73a1fe7a06478c8f85a1"
Expand Down

0 comments on commit d924672

Please sign in to comment.