From 1fc78ebb4c6e2cf71efb466ec7e95465602c1e24 Mon Sep 17 00:00:00 2001 From: Cafe137 <77121044+Cafe137@users.noreply.github.com> Date: Thu, 31 Aug 2023 11:13:58 +0200 Subject: [PATCH] feat: add debug status endpoint (#864) * feat: add debug status endpoint * docs: add jsdoc --- src/bee-debug.ts | 10 ++++++++++ src/modules/debug/status.ts | 13 ++++++++++++- src/types/debug.ts | 13 +++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/bee-debug.ts b/src/bee-debug.ts index c5c5284f..d5dfca4d 100644 --- a/src/bee-debug.ts +++ b/src/bee-debug.ts @@ -19,6 +19,7 @@ import type { ChainState, ChequebookAddressResponse, ChequebookBalanceResponse, + DebugStatus, ExtendedTag, Health, LastCashoutActionResponse, @@ -358,6 +359,15 @@ export class BeeDebug { return settlements.getAllSettlements(this.getRequestOptionsForCall(options)) } + /** + * Get status of node + */ + async getStatus(options?: BeeRequestOptions): Promise { + assertRequestOptions(options) + + return status.getDebugStatus(this.getRequestOptionsForCall(options)) + } + /** * Get health of node */ diff --git a/src/modules/debug/status.ts b/src/modules/debug/status.ts index e9984b72..1c12ed19 100644 --- a/src/modules/debug/status.ts +++ b/src/modules/debug/status.ts @@ -1,6 +1,6 @@ import getMajorSemver from 'semver/functions/major.js' import { BeeRequestOptions } from '../../index' -import type { Health, NodeInfo } from '../../types/debug' +import type { DebugStatus, Health, NodeInfo } from '../../types/debug' import { BeeVersions } from '../../types/debug' import { http } from '../../utils/http' @@ -13,9 +13,20 @@ export const SUPPORTED_DEBUG_API_VERSION = '4.0.0' export const SUPPORTED_BEE_VERSION = SUPPORTED_BEE_VERSION_EXACT.substring(0, SUPPORTED_BEE_VERSION_EXACT.indexOf('-')) const NODE_INFO_URL = 'node' +const STATUS_URL = 'status' const HEALTH_URL = 'health' const READINESS_URL = 'readiness' +export async function getDebugStatus(requestOptions: BeeRequestOptions): Promise { + const response = await http(requestOptions, { + method: 'get', + url: STATUS_URL, + responseType: 'json', + }) + + return response.data +} + /** * Get health of node * diff --git a/src/types/debug.ts b/src/types/debug.ts index f3ef26fd..22a5b7ba 100644 --- a/src/types/debug.ts +++ b/src/types/debug.ts @@ -143,6 +143,19 @@ export interface BalanceResponse { balances: PeerBalance[] } +export interface DebugStatus { + peer: string + proximity: number + beeMode: BeeModes + reserveSize: number + pullsyncRate: number + storageRadius: number + connectedPeers: number + neighborhoodSize: number + batchCommitment: number + isReachable: boolean +} + export interface Health { status: 'ok' version: string