mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-14 23:47:00 +03:00
Properly catch user counter errors
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
var request = require('request');
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
const config = require('../config.js');
|
const config = require('../config.js');
|
||||||
const getIP = require('../utils/getIP.js');
|
const getIP = require('../utils/getIP.js');
|
||||||
@@ -6,11 +6,8 @@ const getHash = require('../utils/getHash.js');
|
|||||||
const logger = require('../utils/logger.js');
|
const logger = require('../utils/logger.js');
|
||||||
|
|
||||||
module.exports = function userCounter(req, res, next) {
|
module.exports = function userCounter(req, res, next) {
|
||||||
try {
|
fetch(config.userCounterURL + "/api/v1/addIP?hashedIP=" + getHash(getIP(req), 1), { method: "POST" })
|
||||||
request.post(config.userCounterURL + "/api/v1/addIP?hashedIP=" + getHash(getIP(req), 1));
|
.catch(() => logger.debug("Failing to connect to user counter at: " + config.userCounterURL))
|
||||||
} catch(e) {
|
|
||||||
logger.debug("Failing to connect to user counter at: " + config.userCounterURL);
|
|
||||||
}
|
|
||||||
|
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user