@simonbackx/simple-endpoints
Advanced tools
Comparing version 1.9.2 to 1.10.0
@@ -26,2 +26,3 @@ /// <reference types="node" /> | ||
static buildJson(method: HttpMethod, url: string, host?: string, body?: any): Request; | ||
getIP(): string; | ||
/** | ||
@@ -28,0 +29,0 @@ * Return the number in the X-Version header or throw if invalid |
@@ -65,2 +65,13 @@ "use strict"; | ||
} | ||
getIP() { | ||
var _a; | ||
let ipAddress = (_a = this.request) === null || _a === void 0 ? void 0 : _a.socket.remoteAddress; | ||
if (this.headers["x-real-ip"] && typeof this.headers["x-real-ip"] == "string" && (ipAddress == "127.0.0.1" || ipAddress == "0.0.0.0")) { | ||
ipAddress = this.headers["x-real-ip"]; | ||
} | ||
if (!ipAddress) { | ||
ipAddress = '?'; | ||
} | ||
return ipAddress.split(":", 2)[0]; | ||
} | ||
/** | ||
@@ -67,0 +78,0 @@ * Return the number in the X-Version header or throw if invalid |
@@ -5,3 +5,3 @@ { | ||
"types": "./dist/index.d.ts", | ||
"version": "1.9.2", | ||
"version": "1.10.0", | ||
"scripts": { | ||
@@ -8,0 +8,0 @@ "test": "jest --setupFiles dotenv/config", |
Sorry, the diff of this file is not supported yet
65083
1036