Store request stats in a sorted set

This commit is contained in:
Michael Jackson 2016-04-12 05:04:55 -07:00
parent 277e938884
commit f3c5dcee2b
1 changed files with 4 additions and 2 deletions

View File

@ -15,8 +15,10 @@ const requestLogging = (redisURL) => {
return (req, res, next) => {
onFinished(res, () => {
if (res.statusCode === 200)
redisClient.incr(req.path)
const path = req.path
if (res.statusCode === 200 && path.charAt(path.length - 1) !== '/')
redisClient.zincrby('requests', 1, req.path)
})
next()