mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2026-02-01 07:10:55 +03:00
everything to postClearCache
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import fetch from "node-fetch";
|
||||
import axios from "axios";
|
||||
import {Logger} from "../utils/logger";
|
||||
import {config} from "../config";
|
||||
import {getIP} from "../utils/getIP";
|
||||
@@ -6,7 +6,7 @@ import {getHash} from "../utils/getHash";
|
||||
import {NextFunction, Request, Response} from "express";
|
||||
|
||||
export function userCounter(req: Request, res: Response, next: NextFunction): void {
|
||||
fetch(`${config.userCounterURL}/api/v1/addIP?hashedIP=${getHash(getIP(req), 1)}`, {method: "POST"})
|
||||
axios.post(`${config.userCounterURL}/api/v1/addIP?hashedIP=${getHash(getIP(req), 1)}`)
|
||||
.catch(() => Logger.debug(`Failing to connect to user counter at: ${config.userCounterURL}`));
|
||||
|
||||
next();
|
||||
|
||||
@@ -2,6 +2,7 @@ import {db} from "../databases/databases";
|
||||
import {config} from "../config";
|
||||
import {Request, Response} from "express";
|
||||
import fetch from "node-fetch";
|
||||
import axios from "axios";
|
||||
import {Logger} from "../utils/logger";
|
||||
|
||||
// A cache of the number of chrome web store users
|
||||
@@ -44,10 +45,9 @@ export async function getTotalStats(req: Request, res: Response): Promise<void>
|
||||
|
||||
function updateExtensionUsers() {
|
||||
if (config.userCounterURL) {
|
||||
fetch(`${config.userCounterURL}/api/v1/userCount`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
apiUsersCache = Math.max(apiUsersCache, data.userCount);
|
||||
axios.get(`${config.userCounterURL}/api/v1/userCount`)
|
||||
.then(res => {
|
||||
apiUsersCache = Math.max(apiUsersCache, res.data.userCount);
|
||||
})
|
||||
.catch(() => Logger.debug(`Failing to connect to user counter at: ${config.userCounterURL}`));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user