File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1282,6 +1282,18 @@ export class Bee {
12821282 return true
12831283 }
12841284
1285+ /**
1286+ * Checks the `/gateway` endpoint to see if the remote API is a gateway.
1287+ *
1288+ * Do note that this is not a standard way to check for gateway nodes,
1289+ * but some of the gateway tooling expose this endpoint.
1290+ *
1291+ * @param options
1292+ */
1293+ async isGateway ( options ?: BeeRequestOptions ) : Promise < boolean > {
1294+ return status . isGateway ( this . getRequestOptionsForCall ( options ) )
1295+ }
1296+
12851297 // Legacy debug API
12861298
12871299 async getNodeAddresses ( options ?: BeeRequestOptions ) : Promise < NodeAddresses > {
Original file line number Diff line number Diff line change 1+ import { Types } from 'cafe-utility'
12import { BeeRequestOptions } from '../index'
23import { http } from '../utils/http'
34
@@ -11,3 +12,15 @@ export async function checkConnection(requestOptions: BeeRequestOptions): Promis
1112 url : '' ,
1213 } )
1314}
15+
16+ export async function isGateway ( requestOptions : BeeRequestOptions ) : Promise < boolean > {
17+ try {
18+ const response = await http < unknown > ( requestOptions , {
19+ url : '/gateway' ,
20+ } )
21+ const data = Types . asObject ( response . data )
22+ return Types . asBoolean ( data . gateway )
23+ } catch ( error ) {
24+ return false
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments