Skip to content

Commit

Permalink
Feat/manage kvs (#79)
Browse files Browse the repository at this point in the history
* add kv list and del requests

* add KV type and change return type to 'all' function
  • Loading branch information
kevin-btc authored Oct 2, 2023
1 parent d22274a commit f6460c0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -56,7 +64,7 @@ export async function get(key: string, clientOptions: InputClientOptions = {}):
}
}

export async function all(clientOptions: InputClientOptions = {}): Promise<string[]> {
export async function all(clientOptions: InputClientOptions = {}): Promise<KV[]> {
try {
const { token, endpoint } = await defaultOptions(clientOptions);

Expand Down Expand Up @@ -104,7 +112,8 @@ export type KVClient = {
get: (key: string) => Promise<string>;
set: (key: string, value: string) => Promise<void>;
del: (key: string) => Promise<void>;
all: () => Promise<string[]>;
all: () => Promise<KV[]>;

};

export default function client(clientOptions: InputClientOptions = {}): KVClient {
Expand Down

0 comments on commit f6460c0

Please sign in to comment.