From 67601ea97f0a3981b9af5a0175c70f6ea3690f15 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Wed, 27 Jun 2018 14:23:14 -0700 Subject: [PATCH] added torCheck to middleware --- .../{routes/utils => middleware}/multipartMiddleware.js | 0 server/middleware/torCheckMiddleware.js | 9 +++++++++ server/routes/api/index.js | 5 +++-- 3 files changed, 12 insertions(+), 2 deletions(-) rename server/{routes/utils => middleware}/multipartMiddleware.js (100%) create mode 100644 server/middleware/torCheckMiddleware.js diff --git a/server/routes/utils/multipartMiddleware.js b/server/middleware/multipartMiddleware.js similarity index 100% rename from server/routes/utils/multipartMiddleware.js rename to server/middleware/multipartMiddleware.js diff --git a/server/middleware/torCheckMiddleware.js b/server/middleware/torCheckMiddleware.js new file mode 100644 index 00000000..df424e3a --- /dev/null +++ b/server/middleware/torCheckMiddleware.js @@ -0,0 +1,9 @@ +const logger = require('winston'); + +const torCheck = (req, res, next) => { // custom logging middleware to log all incoming http requests + const { ip } = req; + logger.debug(`tor check for ${ip}`); + next(); +}; + +module.exports = torCheck; diff --git a/server/routes/api/index.js b/server/routes/api/index.js index 6a89348d..a8bc233c 100644 --- a/server/routes/api/index.js +++ b/server/routes/api/index.js @@ -15,7 +15,8 @@ const fileAvailability = require('../../controllers/api/file/availability'); const userPassword = require('../../controllers/api/user/password'); const publishingConfig = require('../../controllers/api/config/site/publishing'); -const multipartMiddleware = require('../utils/multipartMiddleware'); +const multipartMiddleware = require('../../middleware/multipartMiddleware'); +const torCheckMiddleware = require('../../middleware/torCheckMiddleware'); module.exports = (app) => { // channel routes @@ -30,7 +31,7 @@ module.exports = (app) => { app.get('/api/claim/get/:name/:claimId', claimGet); app.get('/api/claim/list/:name', claimList); app.post('/api/claim/long-id', claimLongId); // should be a get - app.post('/api/claim/publish', multipartMiddleware, claimPublish); + app.post('/api/claim/publish', torCheckMiddleware, multipartMiddleware, claimPublish); app.get('/api/claim/resolve/:name/:claimId', claimResolve); app.get('/api/claim/short-id/:longId/:name', claimShortId); // file routes