Rewrite frontend using create-react-app

This commit is contained in:
MICHAEL JACKSON
2017-03-25 23:53:54 -07:00
parent 69a578fcda
commit 0f5c584104
60 changed files with 20489 additions and 18930 deletions

31
server/logging.js Normal file
View File

@ -0,0 +1,31 @@
const redis = require('redis')
const onFinished = require('on-finished')
const URLFormat = /^\/((?:@[^\/@]+\/)?[^\/@]+)(?:@([^\/]+))?(\/.*)?$/
const logPackageRequests = (redisURL) => {
const redisClient = redis.createClient(redisURL)
return (req, res, next) => {
onFinished(res, () => {
const path = req.path
if (res.statusCode === 200 && path.charAt(path.length - 1) !== '/') {
//redisClient.zincrby([ 'request-paths', 1, path ])
const match = URLFormat.exec(path)
if (match) {
const packageName = match[1]
redisClient.zincrby([ 'package-requests', 1, packageName ])
}
}
})
next()
}
}
module.exports = {
logPackageRequests
}