From 9381525d0573cf9ba6ff275cab6fe926d81485b2 Mon Sep 17 00:00:00 2001 From: MICHAEL JACKSON Date: Wed, 19 Apr 2017 16:35:55 -0700 Subject: [PATCH] Remove logging of package requests --- package.json | 1 - server/index.js | 4 ---- server/logging.js | 31 ------------------------------- 3 files changed, 36 deletions(-) delete mode 100644 server/logging.js diff --git a/package.json b/package.json index 03d3e12..270d374 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ "express-unpkg": "^1.1.1", "http-client": "^4.3.1", "morgan": "^1.8.1", - "on-finished": "^2.3.0", "pretty-bytes": "^3", "prop-types": "^15.5.8", "react": "^15.5.4", diff --git a/server/index.js b/server/index.js index d5a4e1b..1f7d2c0 100644 --- a/server/index.js +++ b/server/index.js @@ -5,7 +5,6 @@ const cors = require('cors') const morgan = require('morgan') const unpkg = require('express-unpkg') const { fetchStats } = require('./cloudflare') -const { logPackageRequests } = require('./logging') const fs = require('fs') const path = require('path') @@ -52,9 +51,6 @@ const createServer = (config) => { maxAge: config.maxAge })) - if (config.redisURL) - app.use(logPackageRequests(config.redisURL)) - app.use(unpkg.createRequestHandler(config)) const server = http.createServer(app) diff --git a/server/logging.js b/server/logging.js deleted file mode 100644 index 6164179..0000000 --- a/server/logging.js +++ /dev/null @@ -1,31 +0,0 @@ -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 -}