2.1.2 • Published 6 years ago

middleware-log v2.1.2

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

日志中间件记录

Document

参数说明

   const setting={
      expires: 60000, // 请求访问时间,单位毫秒
      times: 3, // 请求访问次数
      saveLen: 10, // 应保存请求记录数
      gapLen: 1, // 触发检查请求记录数间隔
      flag:"flag"//请求标志,如果为function,则传人request对象
      recordSetting: null,
      /**
      *存储记录数据配置,默认为不存储,即为null
      *recordSetting: {
      *timeGap: 3000, //访问记录轮询间隔,
      *redis: null,  //redis实例
      *redis_key: "jackChen" //存储键名
      }
   }

Example

const app = express();
const memorySetting = {
    expires: 6000,
    times: 2,
    flag: 'token'
};
const type="query"//支持query,body,param,如果flag为函数,则无需传入,默认为query
const memoryRateMiddle = new RateMiddleware(memorySetting, (err, req, res, next)=>{
    if (err) {
        console.log(err)
        return res.json(err);
    }
    next();
}).make(type) 

app.get('/test/rate/memory', memoryRateMiddle, function(req, res) {
    res.end('test rate_memory success');
});
2.1.2

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago