From a2beda47f5285fbfa6cbde83db4541be0828c365 Mon Sep 17 00:00:00 2001 From: kev Date: Mon, 2 Oct 2023 10:39:49 +0200 Subject: [PATCH] Feat/manage kvs (#79) * add kv list and del requests * add KV type and change return type to 'all' function --- lib/kv.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/kv.ts b/lib/kv.ts index 7336abf..357088c 100644 --- a/lib/kv.ts +++ b/lib/kv.ts @@ -2,6 +2,14 @@ import axios, { AxiosError } from "axios"; import { InputClientOptions, defaultOptions } from "./clientOpts"; import { ApiError, ErrorData } from "./helpers/error"; +export type KV = { + id?: string; + userId?: string; + key: string; + value: string; + createdAt?: string; +}; + export async function set( key: string, value: string, @@ -56,7 +64,7 @@ export async function get(key: string, clientOptions: InputClientOptions = {}): } } -export async function all(clientOptions: InputClientOptions = {}): Promise { +export async function all(clientOptions: InputClientOptions = {}): Promise { try { const { token, endpoint } = await defaultOptions(clientOptions); @@ -104,7 +112,8 @@ export type KVClient = { get: (key: string) => Promise; set: (key: string, value: string) => Promise; del: (key: string) => Promise; - all: () => Promise; + all: () => Promise; + }; export default function client(clientOptions: InputClientOptions = {}): KVClient {