Skip to content

Commit

Permalink
chore: Apply rate limiter to all requests in server.js (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmservera authored Jul 22, 2024
1 parent 86a1e51 commit dded61a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ai/copilot/contoso-real-state-plugin/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ import cors from "cors";

const app = express();

// set up rate limiter: maximum of five requests per minute
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);

//add logging to app
app.use((req, res, next) => {
console.log(`${req.method} request for ${req.url}`);
Expand Down

0 comments on commit dded61a

Please sign in to comment.