-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.js
38 lines (33 loc) · 744 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*!
* koa-better-ratelimit <https://github.com/tunnckoCore/koa-better-ratelimit>
*
* Copyright (c) 2014-2016 Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)
* Released under the MIT license.
*/
/* jshint asi:true */
'use strict'
const ratelimit = require('./index')
const Koa = require('koa2')
const app = new Koa()
app
.use(function * (next) {
try {
yield * next
} catch (e) {
console.log('err', e)
}
})
.use(ratelimit({
// it can be double star - globstar
// or *.*.*.*
id: function () {
return '0.0.0.0'
},
duration: 1000 * 20,
// filter: '*.*.*.*',
max: 2,
throw: true
}))
// .listen(2222, function () {
// console.log('Foo bar baz!')
// })