Package Exports
- @canmertinyo/rate-limit-express
- @canmertinyo/rate-limit-express/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@canmertinyo/rate-limit-express) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Express Rate Limiter
A simple in-memory rate-limiting middleware for Express.js to restrict the number of requests a client can make within a given time. Ideal for lightweight use cases
To install :
npm i @canmertinyo/rate-limit-expressExample usage :
import express from "express";
import { rateLimiter } from "@canmertinyo/rate-limit-express";
const app = express();
// Apply rate limiter middleware
app.use(
rateLimiter({
ms: 60000, // Time in milliseconds
maxRequest: 5, // Maximum requests allowed within the time
})
);
app.get("/", (req, res) => {
res.send("Welcome to the API!");
});
app.listen(3000, () => {
console.log("Server is running on http://localhost:3000");
});