Skip to content

Commit

Permalink
add KV type and change return type to 'all' function
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-btc committed Oct 2, 2023
1 parent 0b0a37a commit 1494c1d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 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,7 @@ 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 1494c1d

Please sign in to comment.