From 6992b870333167bf67ffcd73960a62ea57b255ce Mon Sep 17 00:00:00 2001 From: Jessop Breth Date: Wed, 5 Jun 2019 10:08:13 -0400 Subject: [PATCH] stops logging metrics to localdb --- server/index.js | 7 ++----- server/middleware/httpContextMiddleware.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 server/middleware/httpContextMiddleware.js diff --git a/server/index.js b/server/index.js index e3806779..87455cea 100644 --- a/server/index.js +++ b/server/index.js @@ -20,10 +20,7 @@ const { setupBlockList } = require('./utils/blockList'); const speechPassport = require('./speechPassport'); const processTrending = require('./utils/processTrending'); -const { - logMetricsMiddleware, - setRouteDataInContextMiddleware, -} = require('./middleware/logMetricsMiddleware'); +const { setRouteDataInContextMiddleware } = require('./middleware/httpContextMiddleware'); const { details: { port: PORT, blockListEndpoint }, @@ -145,7 +142,7 @@ function Server() { app[routeMethod]( routePath, - logMetricsMiddleware, + // logMetricsMiddleware, setRouteDataInContextMiddleware(routePath, routeData), ...controllers ); diff --git a/server/middleware/httpContextMiddleware.js b/server/middleware/httpContextMiddleware.js new file mode 100644 index 00000000..b41c602f --- /dev/null +++ b/server/middleware/httpContextMiddleware.js @@ -0,0 +1,13 @@ +const httpContext = require('express-http-context'); + +function setRouteDataInContextMiddleware(routePath, routeData) { + return function(req, res, next) { + httpContext.set('routePath', routePath); + httpContext.set('routeData', routeData); + next(); + }; +} + +module.exports = { + setRouteDataInContextMiddleware, +}; -- 2.45.2