Skip to content

Commit

Permalink
docs: add example of usage
Browse files Browse the repository at this point in the history
  • Loading branch information
YaaY committed Mar 4, 2024
1 parent c1ead4a commit 9a2a15f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions example/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import express from 'express';
import { rateLimiter } from '../throttle';

const app = express();
const PORT = 3000;

app.use(rateLimiter({
windowMs: 60000, // 1 minute
maxRequests: 5, // Limit each IP to 5 requests per windowMs
}));

app.get('/', (req, res) => {
res.send('Hello, world!');
});

app.listen(PORT, () => console.log(`Server running on http://localhost:${PORT}`));

0 comments on commit 9a2a15f

Please sign in to comment.