@bitrix24/b24jssdk
Version:
Bitrix24 REST API JavaScript SDK
57 lines (54 loc) • 1.91 kB
JavaScript
/**
* @package @bitrix24/b24jssdk
* @version 1.0.5
* @copyright (c) 2026 Bitrix24
* @license MIT
* @see https://github.com/bitrix24/b24jssdk
* @see https://bitrix24.github.io/b24jssdk/
*/
import { AbstractTool } from './abstract-tool.mjs';
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
class Ping extends AbstractTool {
static {
__name(this, "Ping");
}
/**
* Measures the response speed of the Bitrix24 REST API.
* Performs a test request and returns the response time in milliseconds.
* Useful for performance monitoring and diagnosing latency issues.
*
* @note The method uses a minimal API request (`server.time`) to check availability.
* Does not overload the server with large amounts of data.
*
* @warning Response time may vary depending on server load, network conditions
* and HTTP client settings (timeouts, retries).
*
* @tip For consistent results, it is recommended to perform multiple measurements
* and use the median value.
*
* @param options Some options for executing
* - `requestId?: string` - Unique request identifier for tracking. Used for query deduplication and debugging (default: undefined)
*
* @returns {Promise<number>} Promise that resolves to a response time in milliseconds:
* - Positive number: time from sending the request to receiving the response
* - In case of an error or timeout: `-1`
*
* @see {@link HealthCheck} To check API availability
*/
async make(options) {
const startTime = Date.now();
try {
await this._b24.actions.v2.call.make({
method: "server.time",
params: {},
requestId: options?.requestId
});
return Date.now() - startTime;
} catch {
return -1;
}
}
}
export { Ping };
//# sourceMappingURL=ping.mjs.map