MIDDLEWARES
Rate Limit
Introduction

Introduction

The Rate Limit middleware is designed to control the request rate from clients by limiting the number of requests that can be made within a specified time window. It is useful for protecting APIs against overuse or abuse by rate-limiting requests based on configurable parameters such as time window and request limit.

Quick Start

import v from "vkrun"
 
const vkrun = v.App()
vkrun.rateLimit({ windowMs: 15 * 60 * 1000, limit: 100 }) // 100 requests per 15 minutes
 
vkrun.get("/rate-limit", (request: v.Request, response: v.Response) => {
  response.status(200).send("Rate limit applied!")
})
 
vkrun.server().listen(3000, () => {
  console.log("Server started on port 3000 with Rate Limit enabled")
})
Copyright © 2024 - 2025 MIT by Mario Elvio