updown.io
Version:
An updown.io API client
30 lines (29 loc) • 898 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.UpdownIO = void 0;
const axios_1 = require("axios");
const api_1 = require("./api");
class UpdownIO {
constructor(options) {
if (typeof options === 'string') {
options = { apiKey: options };
}
this.apiClient = axios_1.default.create({
baseURL: 'https://updown.io/api/',
headers: Object.assign({}, (options && options.apiKey && { 'X-API-KEY': options.apiKey })),
});
this.api = {
checks: new api_1.ChecksAPI(this.apiClient),
nodes: new api_1.NodesAPI(this.apiClient),
};
}
/**
* Set a new API URL.
* @param newUrl The new API url
*/
setApiUrl(newUrl) {
this.api.checks.setApiUrl(newUrl);
this.api.nodes.setApiUrl(newUrl);
}
}
exports.UpdownIO = UpdownIO;