watchtower-node-sdk
Version:
A TypeScript Node.js SDK for the Watchtower API, providing API key management, connection string generation, and more
86 lines • 3.29 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WatchtowerSDK = void 0;
const axios_1 = __importDefault(require("axios"));
const handler_1 = require("./endpoints/health/handler");
const handler_2 = require("./endpoints/apikey/handler");
const handler_3 = require("./endpoints/logs/handler");
const handler_4 = require("./endpoints/metrics/handler");
const handler_5 = require("./endpoints/items/handler");
const handler_6 = require("./endpoints/intelligence/handler");
const handler_7 = require("./endpoints/analyze/handler");
const handler_8 = require("./endpoints/app/handler");
const handler_9 = require("./endpoints/connectionstring/handler");
const BASE_URL = 'https://watchtower-go-supabase-822142465400.europe-west1.run.app';
class WatchtowerSDK {
constructor(config) {
this.client = axios_1.default.create({
baseURL: BASE_URL,
...config,
});
// Initialize endpoints
this.health = new handler_1.HealthEndpoint(this.client);
this.apikey = new handler_2.APIKeyEndpoint(this.client);
this.logs = new handler_3.LogsEndpoint(this.client);
this.metrics = new handler_4.MetricsEndpoint(this.client);
this.items = new handler_5.ItemsEndpoint(this.client);
this.intelligence = new handler_6.IntelligenceEndpoint(this.client);
this.analyze = new handler_7.AnalyzeEndpoint(this.client);
this.app = new handler_8.AppEndpoint(this.client);
this.connectionstring = new handler_9.ConnectionStringEndpoint(this.client);
}
/**
* Make a GET request
* @param url - The endpoint URL
* @param config - Optional Axios request configuration
* @returns Promise with the response data
*/
async get(url, config) {
const response = await this.client.get(url, config);
return response.data;
}
/**
* Make a POST request
* @param url - The endpoint URL
* @param data - The data to send
* @param config - Optional Axios request configuration
* @returns Promise with the response data
*/
async post(url, data, config) {
const response = await this.client.post(url, data, config);
return response.data;
}
/**
* Make a PUT request
* @param url - The endpoint URL
* @param data - The data to send
* @param config - Optional Axios request configuration
* @returns Promise with the response data
*/
async put(url, data, config) {
const response = await this.client.put(url, data, config);
return response.data;
}
/**
* Make a DELETE request
* @param url - The endpoint URL
* @param config - Optional Axios request configuration
* @returns Promise with the response data
*/
async delete(url, config) {
const response = await this.client.delete(url, config);
return response.data;
}
/**
* Get the underlying Axios instance
* @returns The Axios instance
*/
getClient() {
return this.client;
}
}
exports.WatchtowerSDK = WatchtowerSDK;
//# sourceMappingURL=index.js.map