updated logging

This commit is contained in:
bill bittner 2018-06-27 15:01:40 -07:00
parent 67601ea97f
commit 097ef744d7
2 changed files with 18 additions and 12 deletions

View file

@ -1,5 +1,3 @@
const logger = require('winston');
const { details: { host }, publishing: { disabled, disabledMessage } } = require('@config/siteConfig');
const { sendGATimingEvent } = require('../../../../utils/googleAnalytics.js');
@ -22,12 +20,6 @@ const authenticateUser = require('./authentication.js');
*/
const claimPublish = ({ body, files, headers, ip, originalUrl, user }, res) => {
// logging
logger.info('PUBLISH REQUEST:', {
ip,
headers,
body,
});
// check for disabled publishing
if (disabled) {
return res.status(503).json({

View file

@ -1,9 +1,23 @@
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();
function ipIsInTorList (ip) {
return true;
}
const torCheck = ({ ip, headers, body }, res, next) => {
logger.debug(`tor check for:`, {
ip,
headers,
body,
});
// check the tor node list
if (ipIsInTorList(ip)) {
return res.status('400').json({
success: 'false',
message: 'Unfortunately this api route is not currently available for tor users. We are working on a solution that will allow tor users to publish in the future.',
});
};
return next();
};
module.exports = torCheck;