mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-09 13:07:02 +03:00
migrate to typescript
This commit is contained in:
committed by
Dainius Dauksevicius
parent
c462323dd5
commit
08d27265fc
13
src/middleware/userCounter.ts
Normal file
13
src/middleware/userCounter.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import fetch from 'node-fetch';
|
||||
import {Logger} from '../utils/logger';
|
||||
import {config} from '../config';
|
||||
import {getIP} from '../utils/getIP';
|
||||
import {getHash} from '../utils/getHash';
|
||||
import {NextFunction, Request, Response} from 'express';
|
||||
|
||||
export function userCounter(req: Request, res: Response, next: NextFunction) {
|
||||
fetch(config.userCounterURL + "/api/v1/addIP?hashedIP=" + getHash(getIP(req), 1), {method: "POST"})
|
||||
.catch(() => Logger.debug("Failing to connect to user counter at: " + config.userCounterURL));
|
||||
|
||||
next();
|
||||
}
|
||||
Reference in New Issue
Block a user