fixed findall raw query
This commit is contained in:
parent
a3df219684
commit
aed4e05b24
2 changed files with 27 additions and 18 deletions
|
@ -32,8 +32,8 @@ const getTorList = (req, res) => {
|
|||
.then(() => {
|
||||
return db.Tor.findAll({
|
||||
attributes: ['address', 'fingerprint'],
|
||||
})
|
||||
.map(el => el.get({ plain: true }));
|
||||
raw: true,
|
||||
});
|
||||
})
|
||||
.then( result => {
|
||||
logger.debug('number of records', result.length);
|
||||
|
|
|
@ -1,23 +1,32 @@
|
|||
const logger = require('winston');
|
||||
|
||||
function ipIsInTorList (ip) {
|
||||
return true;
|
||||
}
|
||||
const db = require('../models');
|
||||
|
||||
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({
|
||||
logger.debug(`tor check for: ${ip}`);
|
||||
return db.Tor.findAll(
|
||||
{
|
||||
where: {
|
||||
address: ip,
|
||||
},
|
||||
raw: true,
|
||||
})
|
||||
.then(result => {
|
||||
logger.debug('tor check results:', result);
|
||||
if (result.length >= 1) {
|
||||
logger.debug('this is a tor ip');
|
||||
const failureResponse = {
|
||||
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 use this endpoint in the future.',
|
||||
});
|
||||
}
|
||||
};
|
||||
return res.status(400).json(failureResponse);
|
||||
} else {
|
||||
logger.debug('this is not a tor ip');
|
||||
return next();
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error(error);
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = torCheck;
|
||||
|
|
Loading…
Reference in a new issue