Store request stats in a sorted set
This commit is contained in:
parent
277e938884
commit
f3c5dcee2b
|
@ -15,8 +15,10 @@ const requestLogging = (redisURL) => {
|
||||||
|
|
||||||
return (req, res, next) => {
|
return (req, res, next) => {
|
||||||
onFinished(res, () => {
|
onFinished(res, () => {
|
||||||
if (res.statusCode === 200)
|
const path = req.path
|
||||||
redisClient.incr(req.path)
|
|
||||||
|
if (res.statusCode === 200 && path.charAt(path.length - 1) !== '/')
|
||||||
|
redisClient.zincrby('requests', 1, req.path)
|
||||||
})
|
})
|
||||||
|
|
||||||
next()
|
next()
|
||||||
|
|
Loading…
Reference in New Issue