UNPKG

helix-ts

Version:

TypeScript Library for working with HelixDB

29 lines 745 B
// src/index.ts var HelixDB = class { url; apiKey; /** * Create a new HelixDB client * @param url - The url of the HelixDB server (default: `http://localhost:6969`) * @param apiKey - The api key of the HelixDB server (default: `null`) */ constructor(url = "http://localhost:6969", apiKey = null) { this.url = url; this.apiKey = apiKey; } async query(endpoint, data) { const response = await fetch(`${this.url}/${endpoint}`, { method: "POST", headers: { "Content-Type": "application/json", ...this.apiKey ? { "x-api-key": this.apiKey } : {} }, body: JSON.stringify(data) }); return response.json(); } }; export { HelixDB }; //# sourceMappingURL=index.mjs.map