ratelimit for koa extend
$ npm install @koex/ratelimit
// See more in test
import ratelimit from '@koex/ratelimit';
import * as Koa from 'koa';
const app = new Koa();
app.use(ratelimit());
app.use(async (ctx) => {
if (ctx.path === '/') {
ctx.body = 'hello, world';
} else if (ctx.path === '/json') {
ctx.body = {
name: 'name',
value: 'value',
};
}
});
app.listen(8000, '0.0.0.0', () => {
console.log('koa server start');
});