add userCounter mocks and rearrange webhook path

This commit is contained in:
Michael C
2022-09-21 01:14:22 -04:00
parent 3f470a72f5
commit f683ed4f29
6 changed files with 35 additions and 15 deletions

View File

@@ -3,6 +3,9 @@ import { Request } from "express";
import { IPAddress } from "../types/segments.model";
export function getIP(req: Request): IPAddress {
// if in testing mode, return immediately
if (config.mode === "test") return "127.0.0.1" as IPAddress;
if (config.behindProxy === true || config.behindProxy === "true") {
config.behindProxy = "X-Forwarded-For";
}
@@ -15,6 +18,6 @@ export function getIP(req: Request): IPAddress {
case "X-Real-IP":
return req.headers["x-real-ip"] as IPAddress;
default:
return (req.connection?.remoteAddress || req.socket?.remoteAddress) as IPAddress;
return req.socket?.remoteAddress as IPAddress;
}
}