UNPKG

textiot

Version:

A framework for building web and native (IoT) Dapps on the IPFS network

62 lines (61 loc) 2.25 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const api_1 = require("../core/api"); /** * Utils is an API module for various Textile node utilities * * @extends API */ class Utils extends api_1.API { /** * Get the current node's API, and application versions * @returns Version of Cafe API and node binary release */ version() { return __awaiter(this, void 0, void 0, function* () { const response = yield this.sendGet('../../'); return response.json(); }); } /** * Get a summary of all local node data * @returns Summary of node activity */ summary() { return __awaiter(this, void 0, void 0, function* () { const response = yield this.sendGet('summary'); return response.json(); }); } /** * Pings another peer on the network, returning wherther they are online or offline. * @param id The peer id * @returns Whether the peer is online */ ping(id) { return __awaiter(this, void 0, void 0, function* () { const response = yield this.sendGet('ping', [id]); return response.text(); }); } /** * Check whether the underlying node's API is online * @returns Whether the API is online */ online() { return __awaiter(this, void 0, void 0, function* () { const response = yield this.sendGet('../../health'); return response.status === 204; }); } } exports.default = Utils;