From 1946eabe31d94fe0cab8ef99e2a2985ad6685fe4 Mon Sep 17 00:00:00 2001 From: Waradu Date: Sat, 10 May 2025 15:18:40 +0200 Subject: [PATCH] feat: json --- src/index.d.ts | 3 ++- src/index.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/index.d.ts b/src/index.d.ts index 0a80e14..e02c484 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -49,7 +49,8 @@ export class WireKVSDatabase extends EventEmitter { disconnect(): void; getAllEntries(): Promise; - get(key: string): Promise; + get(key: string): Promise; + json(key: string): Promise; set(key: string, value: any): Promise; update(key: string, value: any): Promise; delete(key: string): Promise; diff --git a/src/index.js b/src/index.js index 204d0b6..c837e9b 100644 --- a/src/index.js +++ b/src/index.js @@ -130,6 +130,16 @@ class WireKVSDatabase extends EventEmitter { return response.data; } + async json(key) { + const response = await axios.get( + `${API_BASE_URL}/database/${this.id}/${key}`, + { + headers: { Authorization: this.accessKey }, + } + ); + return JSON.parse(response.data); + } + async set(key, value) { await axios.post(`${API_BASE_URL}/database/${this.id}/${key}`, value, { headers: { Authorization: this.accessKey },