Log reqs based on package as well
This commit is contained in:
parent
5435b3c788
commit
dd04ece3d0
11
server.js
11
server.js
|
@ -17,8 +17,15 @@ const requestLogging = (redisURL) => {
|
||||||
onFinished(res, () => {
|
onFinished(res, () => {
|
||||||
const path = req.path
|
const path = req.path
|
||||||
|
|
||||||
if (res.statusCode === 200 && path.charAt(path.length - 1) !== '/')
|
if (res.statusCode === 200 && path.charAt(path.length - 1) !== '/') {
|
||||||
redisClient.zincrby([ 'requests', 1, req.path ])
|
redisClient.zincrby([ 'requests', 1, path ])
|
||||||
|
|
||||||
|
const packageSpec = path.split('/')[1]
|
||||||
|
const atIndex = packageSpec.lastIndexOf('@')
|
||||||
|
const packageName = packageSpec.substring(0, atIndex)
|
||||||
|
|
||||||
|
redisClient.zincrby([ 'package-requests', 1, packageName ])
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
next()
|
next()
|
||||||
|
|
Loading…
Reference in New Issue