Skip to content

Commit

Permalink
feat: add debug status endpoint (#864)
Browse files Browse the repository at this point in the history
* feat: add debug status endpoint

* docs: add jsdoc
  • Loading branch information
Cafe137 authored Aug 31, 2023
1 parent 3b703d1 commit 1fc78eb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/bee-debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type {
ChainState,
ChequebookAddressResponse,
ChequebookBalanceResponse,
DebugStatus,
ExtendedTag,
Health,
LastCashoutActionResponse,
Expand Down Expand Up @@ -358,6 +359,15 @@ export class BeeDebug {
return settlements.getAllSettlements(this.getRequestOptionsForCall(options))
}

/**
* Get status of node
*/
async getStatus(options?: BeeRequestOptions): Promise<DebugStatus> {
assertRequestOptions(options)

return status.getDebugStatus(this.getRequestOptionsForCall(options))
}

/**
* Get health of node
*/
Expand Down
13 changes: 12 additions & 1 deletion src/modules/debug/status.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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<DebugStatus> {
const response = await http<DebugStatus>(requestOptions, {
method: 'get',
url: STATUS_URL,
responseType: 'json',
})

return response.data
}

/**
* Get health of node
*
Expand Down
13 changes: 13 additions & 0 deletions src/types/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1fc78eb

Please sign in to comment.