# koa-util-limit **Repository Path**: Dream_bin/koa-util-limit ## Basic Information - **Project Name**: koa-util-limit - **Description**: koa的一个限流器 - **Primary Language**: TypeScript - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-10-16 - **Last Updated**: 2025-04-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: 限流器 ## README # koa-util-limit ## Install ```bash $ npm install koa-util-limit ``` ## Usage ```js const koaRateLimit = require("koa-util-limit"); const Redis = require("ioredis"); const koa = require("koa"); const app = koa(); app.use( koaRateLimit({ //memory or redis driver: "redis", //If it is memory, it can be ignored db: new Redis(), //100 calls at most in 60 * 1000ms duration: 60 * 1000, max: 100, //id unique identification id: (ctx) => ctx.ip, //whitelist white: async (ctx) => { //return boolean }, //blacklist black: async (ctx) => { //return boolean }, //namespace namespace: "limit", //error response error: { code: 429, msg: "too many requests", }, }) ); ```