Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add debug status endpoint #864

Merged
merged 2 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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