Comparing version 1.3.1 to 1.3.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const MODULE_VERSION = "1.3.1"; | ||
const MODULE_VERSION = "1.3.2"; | ||
const DEFAULT_API_URL = "https://api.dev-up.ru/method/"; | ||
@@ -5,0 +5,0 @@ class DevUpError extends Error { |
@@ -39,3 +39,17 @@ import { Builder } from "./API/main"; | ||
call(method: string, params?: Record<string, any>): API_Response<any>; | ||
/** | ||
* Позволяет узнать текущий пинг до API | ||
* @returns {Object} response Объект с результатом | ||
* @returns {string} response.host Хост | ||
* @returns {boolean} response.alive Статус API | ||
* @returns {number} response.time Пинг до API | ||
* @returns {string} response.ip IP-адрес API | ||
*/ | ||
ping: () => Promise<{ | ||
host: string; | ||
alive: boolean; | ||
time: number; | ||
ip: string; | ||
}>; | ||
} | ||
export default DevUp; |
@@ -15,2 +15,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const ping_1 = require("ping"); | ||
const main_1 = require("./API/main"); | ||
@@ -42,2 +43,26 @@ const main_2 = __importDefault(require("./API/vk/main")); | ||
super(params); | ||
/** | ||
* Позволяет узнать текущий пинг до API | ||
* @returns {Object} response Объект с результатом | ||
* @returns {string} response.host Хост | ||
* @returns {boolean} response.alive Статус API | ||
* @returns {number} response.time Пинг до API | ||
* @returns {string} response.ip IP-адрес API | ||
*/ | ||
this.ping = () => __awaiter(this, void 0, void 0, function* () { | ||
const url = this.apiURL; | ||
let hostname; | ||
url.indexOf("//") > -1 | ||
? (hostname = url.split("/")[2]) | ||
: (hostname = url.split("/")[0]); | ||
hostname = hostname.split(":")[0]; | ||
hostname = hostname.split("?")[0]; | ||
const PingData = yield ping_1.promise.probe(hostname); | ||
return { | ||
host: PingData.host, | ||
alive: PingData.alive, | ||
time: Number(PingData.time) || 0, | ||
ip: PingData.numeric_host || "0.0.0.0", | ||
}; | ||
}); | ||
this.vk = new main_2.default(params); | ||
@@ -44,0 +69,0 @@ this.profile = new main_3.default(params); |
@@ -1,2 +0,2 @@ | ||
const MODULE_VERSION = "1.3.1"; | ||
const MODULE_VERSION = "1.3.2"; | ||
const DEFAULT_API_URL = "https://api.dev-up.ru/method/"; | ||
@@ -3,0 +3,0 @@ class DevUpError extends Error { |
@@ -39,3 +39,17 @@ import { Builder } from "./API/main"; | ||
call(method: string, params?: Record<string, any>): API_Response<any>; | ||
/** | ||
* Позволяет узнать текущий пинг до API | ||
* @returns {Object} response Объект с результатом | ||
* @returns {string} response.host Хост | ||
* @returns {boolean} response.alive Статус API | ||
* @returns {number} response.time Пинг до API | ||
* @returns {string} response.ip IP-адрес API | ||
*/ | ||
ping: () => Promise<{ | ||
host: string; | ||
alive: boolean; | ||
time: number; | ||
ip: string; | ||
}>; | ||
} | ||
export default DevUp; |
@@ -10,2 +10,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import { promise as ping } from "ping"; | ||
import { Builder } from "./API/main"; | ||
@@ -37,2 +38,26 @@ import VK from "./API/vk/main"; | ||
super(params); | ||
/** | ||
* Позволяет узнать текущий пинг до API | ||
* @returns {Object} response Объект с результатом | ||
* @returns {string} response.host Хост | ||
* @returns {boolean} response.alive Статус API | ||
* @returns {number} response.time Пинг до API | ||
* @returns {string} response.ip IP-адрес API | ||
*/ | ||
this.ping = () => __awaiter(this, void 0, void 0, function* () { | ||
const url = this.apiURL; | ||
let hostname; | ||
url.indexOf("//") > -1 | ||
? (hostname = url.split("/")[2]) | ||
: (hostname = url.split("/")[0]); | ||
hostname = hostname.split(":")[0]; | ||
hostname = hostname.split("?")[0]; | ||
const PingData = yield ping.probe(hostname); | ||
return { | ||
host: PingData.host, | ||
alive: PingData.alive, | ||
time: Number(PingData.time) || 0, | ||
ip: PingData.numeric_host || "0.0.0.0", | ||
}; | ||
}); | ||
this.vk = new VK(params); | ||
@@ -39,0 +64,0 @@ this.profile = new Profile(params); |
{ | ||
"name": "api-devup", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "This library is intended for interaction with the service https://dev-up.ru", | ||
@@ -33,3 +33,4 @@ "main": "./dist/cjs/main.js", | ||
"dependencies": { | ||
"axios": "^0.21.1" | ||
"axios": "^0.21.1", | ||
"ping": "^0.4.0" | ||
}, | ||
@@ -42,4 +43,5 @@ "devDependencies": { | ||
"jsdoc": "^3.6.6", | ||
"typescript": "^4.2.3" | ||
"typescript": "^4.2.3", | ||
"@types/ping": "^0.2.0" | ||
} | ||
} |
@@ -7,2 +7,2 @@ /* eslint-disable */ | ||
test.call("hello").then((res) => console.log(res)); | ||
test.ping().then((res) => console.log(res)); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54896
1470
2
7
+ Addedping@^0.4.0
+ Addedping@0.4.4(transitive)